Translations¶
Overview¶
The XML translation module allows defining and using translated strings directly within XML files.
Usage¶
Example XML translation definition:
In the root <translations>
tag, the languages
attribute defines the available languages,
e.g., languages="en de hu"
. Language codes are free-form, but ISO-style codes are recommended.
Each <translation>
defines a tag
, which acts as the lookup key, and attributes for each language.
Translations may be omitted—Fallbacks will be applied when needed.
To register XML translations:
lv_xml_translation_register_from_file("path/to/file.xml")
lv_xml_translation_register_from_data(xml_string)
Multiple XML sources can be registered; they will be merged and searched collectively.
Usage in XML¶
Some widget properties support a *-translated
suffix to refer to translation tags. For example:
This sets the label's text to the translated string for "dog"
.
More Details¶
For information on selecting the active language, retrieving translations, and fallback behavior, refer to the general LVGL translation module.