Skip to content

Languages

ssbaxys edited this page Oct 26, 2026 · 1 revision

Live language switching and translations.

Language switching is built in and works on the fly: the current language is a signal, so an open screen is translated immediately, without being recreated.

// 1. Translations: the mod's lang files (assets/<mod>/lang/en_us.json, ru_ru.json) are picked up automatically.
//    You can also set them from code:
I18n.translations("en_us").add("mymod.clicks", "Clicks: %s");
I18n.translations("ru_ru").add("mymod.clicks", "Нажатий: %s");
I18n.declareLanguage("en_us");   // which languages to offer in the switcher
I18n.declareLanguage("ru_ru");   // (tables from code declare themselves)

// 2. Translated widgets; a signal argument is inserted and updates by itself.
Label.tr("mymod.clicks", clicks);
Button.tr("mymod.close").onPress(onClose);
new LanguageButton();            // ready button: next language in a cycle

// 3. Control from code.
I18n.setLanguage("ru_ru");       // own language, independent of the game's; the choice is saved
I18n.followGameLanguage();       // follow the game again (default behavior)
  • Lookup order: tables from code → custom sources (I18n.addSource) → the game's lang files; if a key is missing in the current language, en_us is used, then the key itself.
  • I18n.get(key, args) translates "now"; inside Computed/I18n.text(...) it is recomputed when the language changes.
  • Bindings are lazy (Derived): a widget listens to the language only while it is in the tree, so there are no leaks.
  • The choice is stored in config/luminaui.properties; a resource reload (F3+T, changing the game language) re-reads translations.

← HTML and CSS · English home · Config Screen →

Clone this wiki locally