Translation

Report on GitHub

Register multi-language string tables and switch locales at runtime.

Static and dynamic translation packs

Register two translation sources and print labels via lv_tr.

A static pack provides the tags tiger, lion, rabbit, and elephant in English, German, and Spanish through lv_translation_add_static. A dynamic pack built with lv_translation_add_dynamic adds the tags table and chair for English and German using lv_translation_add_tag and lv_translation_set_tag_translation. lv_translation_set_language("de") selects German and two labels render the tiger and chair translations through lv_tr.

Live language switching from a dropdown

Refresh translated labels on LV_EVENT_TRANSLATION_LANGUAGE_CHANGED.

A dropdown lists the entries in the languages array (English, Deutsch, Español). Its LV_EVENT_VALUE_CHANGED callback reads the selected string and calls lv_translation_set_language. One label is created per tag in the tags array and subscribes to LV_EVENT_TRANSLATION_LANGUAGE_CHANGED; the handler rewrites its text with lv_tr(tag). The screen uses a centered column flex layout and starts in English.

How is this guide?

Last updated on

On this page