I’d like the ability for SquareLine Studio to emit code to process a language change without changing screens.
Do you see alternative options and workaround to achieve it?
I was able to fix one page by adding:
lv_label_set_text(ui_lblChooseLanguage, _(“Choose Language:”)), but I don’t want to do this for every widget, and it’s a maintenance headache when my UI engineer improves the text in SLS.
Mention some use cases
A nice language-chooser that updates as the language changes.
Testing each screen: we’d like to able to cycle through languages on the same screen to validate how the widget sizing and flex flows adjust to the varying text lengths.
When you create a project, tick “enable multilanguage” in the Project settings (you can modify this also later on in the file/project settings) After creating the label widget, you will see a “to be translated” checkbox on the inspector panel, below the text. If you tick it, you will have the multilanguage option available. Check out this documentation for more information: Multilanguage | SquareLine Studio
What I’m having trouble with is at runtime, when I switch languages, then I have to change screens before the language update is applied. While I’m on the same screen, the language does not update. Something needs to call lv_label_set_text(ui_lblChooseLanguage, _("Choose Language:")); to trigger the lv_i18n to translate the string and update the label text.
In this video, I’m calling lv_label_set_text() to update the header text manually after calling lv_i18n_set_locale(), but I’d like to request SquareLine Studio generate code to call these instead, as every screen and widget that could be displayed needs reprocessed after calling lv_i18n_set_locale().
Yes, what you’d like to have, changing languages right in SquareLine Studio, would really be a useful feature, no doubt. I cannot promise now but it’s possible it will be added in the future.
I had some project where the language had to be changed on the fly in the exported LVGL code. And yes, you literally need to set the texts on all the widgets on the current screen that are to be translated, in case you don’t want to simply call the screen-init function. (There surely are cases when one doesn’t want to simply reload the screen.)
My idea that could help with this, is to have the text-setter function calls for a screen in a separate function in the exported ui-code, so by calling this you’ll be able to refresh only the texts on a screen when an on-the-fly language change is required. We’ll see if we can modify the export to have this feature…thanks for expressing the need for a capability like this.