Translations
The whole system has one language (Settings › Language). Each crate has its own language files.
<crate>/lang/en.json { "hello.title": "Hello", "hello.count": ["{n} greeting", "{n} greetings"] }
<crate>/lang/de.json { "hello.title": "Hallo", … }
<crate>/lang/template.json every value is its key: shows untranslated text in the UI
Keys are lower case, <area>.<name>. A pair is [one, other] (plural).
Adding text
Always with the script; it writes every language file of the folder and keeps existing translations:
tools/add-translation.py apps/hello/lang hello.title "Hello"
tools/add-translation.py apps/hello/lang hello.count "{n} greeting" "{n} greetings"
In Slint
Text { text: @tr("hello.title"); }
Text { text: @tr("hello.rings-in", root.minutes); } // "Rings in {} min"
Text { text: @tr("hello.count" | "hello.count" % root.n); } // plural
Only keys; no @tr("context" => …). Call taunus_theme::follow_language() after creating the first window.
In Rust
taunus_i18n::load!(); // crate root; build.rs must generate (theme::build does it)
use taunus_i18n::{t, tn};
t!("hello.title");
t!("hello.rings-in", minutes);
tn!("hello.count", n);
Crates without .slint call taunus_i18n::generate::rust() in their build.rs.
Checking
cargo test --release -p taunus-i18n compares every @tr, t! and tn! with the language files.
TAUNUS_LANG=de (or template) runs a program in another language.
A new language
One more <code>.json per crate and an entry in LANGUAGES (libs/i18n/src/lib.rs). Missing keys show
English.
Copy
Say "the device", never a product name. Prefer words that name no gesture ("Select", not "Tap"); where a gesture
must be named, add a .tv variant.