Multi language Support

Hi,
I am trying to implement multi language feature in our application. But failed as i didnot find enough documentation or tutorial or guideline. Only have github Documentation.
in SLS youtuve channel, only a tutorial but this in not enough.

can anyone suggest me how to implement or can you share a file with implemented this feature?

it will be helpful for me.

Thank you everyone.

It seems the lv_i18n project’s own documentation at GitHub - lvgl/lv_i18n: Internationalization (i18n) for LVGL is not adequate for you. I’m afraid there’s no much more official info yet, maybe try LVGL forum to see more. I made multi-lingual project already, but I went the simpler way, not using the suggested method, but creating simple language header-files with arrays of ‘key’,‘value’ pairs directly, manually. It has the disadvantage that the texts set to multilingual in SquareLine Studio are not collected automatically, need to be put in the arrays, but in return there’s no need to bother with that complex node.js + yaml based procedure (which btw might get simpler after one gets used to them). It’s your decision which route you take, I just mentioned an alternative, simpler way.
In a nutshell: Essentially the ‘gettext()’ function (with the used ‘_()’ alias) is the soul of the whole translation. Every string surrounded by (put into) this function call runs the gettext() function with the ‘key’ string (usually the default English text which can also be a shorter custom ID-string for long English texts), which searches for the ‘key’ and associated ‘value’ (the translated text) in a given language’s array. If it doesn’t find a match it returns the original string as a fallback.

Hi,
Thank you @Hermit for your quick reply and suggestion. I think it will be better to follow the standard instruction. i also get failed to implement suggested method by LVGL. here i have get error while try to execute the (lv_i18n.js) file. without execute this file i cannot go forward.

****** Error in VS Code****
C:\Users\utente\Desktop\lv_i18n-master>
[19444:0917/124751.152:ERROR:cache_util_win.cc(20)] Unable to move the cache: Access is denied. (0x5)
[19444:0917/124751.152:ERROR:disk_cache.cc(208)] Unable to create cache


and i have another question to you-
every time when i modify on UI using SLS and export UI file and i replace the file with old. But if i modify in editor of UI files it also replaced. (example if i modify ui.h file in editor).

is there any way that i can modify in SLS and in editor simultaneously?

Thank you so much.

It seems as if you have some permission issue or an intervening antivirus-like software. But I’m not too familiar with this Windows-filesystem related error message, I use Linux. I remember reading somewhere this node.js procedure might not be so Windows-friendly. (LVGL-forum can hold some experience regarding this, like: https://forum.lvgl.io/t/how-to-use-lv-i18n-multilanguage/14219.)
Your 2nd question: you can’t go back-and-forth between SquareLine Studio UI export and VSCode editing. Only ui_events.c is intended to be modified, the other files in ui.h shouldn’t be edited after export.

A few of use users discussed this here: Request for Detailed LVGL Multilanguage Implementation Guide with SquareLine Studio (SLS)

I got it working just fine in Windows 11 by installing node.js, then following the Install/run the script from the lv_i18n github project. I ended up doing a local install of lv_i18n but from github’s repo master branch. A local install will lv_i18n into a subfolder of node_modules in your current directory from the command prompt. Then you can execute the lv_i18n commands in a command prompt like:

node_modules\.bin\lv_i18n extract -s "main/**/*.+(c|cpp|h|hpp)" -t "main/translations/*.yml"
node_modules\.bin\lv_i18n compile -t "main/translations/*.yml" -o "main/lv_i18n"

In these commands, my translations were inside main/translations folder, my source files were in main folder, and the lv_i18n folder was in main/lv_i18n.

1 Like