Localization
Keep translated strings outside Python and use locale fallback and formatting.
Localization
Elyx loads translations from a file or directory declared in refmap.yml:
Recommended layout:
Locale filenames
The locale is the part after the final _ in the filename stem:
Supported formats:
.yaml.yml.json.py
YAML or JSON is recommended. A Python localization file is executed while loading and only simple non-callable public values are collected.
Translation files
strings_en.yml:
strings_ru.yml:
Values may be strings, numbers, lists, or dictionaries.
Read strings
Import the plugin-bound object:
All these forms are supported:
Calling the object also formats a string:
Positional placeholders work too:
Fallback order
For a regular lookup Elyx uses:
- the selected plugin locale
- English (
en) - the requested key itself
Provide an explicit default:
Force a locale:
The selected locale comes from Elyx's language setting. When that setting is empty, the Android system locale is used.
Plural forms
Strings.pluralize uses three Slavic-style forms:
For languages with different plural rules, select the form in plugin code or store complete formatted phrases. The current helper is not a full CLDR pluralization engine.
Localize metadata
Place placeholders in metainfo.yml:
Define the key in every locale:
Description placeholders are resolved when the plugin is loaded. They use the same current-locale-then-English fallback.
Use Strings directly
The public class is useful for an independent in-memory catalog:
Most plugins should use the environment-provided strings, because it already
contains the files declared by the project.
Best practices
- always include English as the fallback locale
- keep stable semantic keys such as
settings_privacy_title - do not concatenate translated fragments to build a sentence
- pass values through
{named}placeholders - keep Markdown links and formatting consistent across translations
- use YAML quotes around text containing
:,{}, or leading special characters
If from elyx import strings fails, the localization path is missing, empty,
or invalid. See Troubleshooting.