This page is docs/languages.md of the repository, as it is on main.
The languages of the window
The window of pantin speaks English, French, Spanish and German. The language is chosen in Edit › Preferences… › General; the first run takes the language of the system when the window speaks it, and English otherwise. The command line and the MCP server speak English.
The texts are files of Fluent, built into the application:
crates/pantin-ui/locales/<code>/pantin.ftl and counts.ftl.
A text in the code
A text is written in English where it is shown, and that English is its key:
ui.button(tr("Draw a bone")); // a text
theme::section(ui, t!("Picture"), |_| {}); // given to a helper that translates it
const STEPS: [&str; 2] = [t!("First"), t!("Then")]; // kept in a constant, tr(step) where shown
tr_args("Exporting { $file }", &[("file", name.into())]); // a text with values
tr_id("bone-count", &[("count", bones.into())]); // words that change with a number
Its identifier in the files is made of its words (draw-a-bone, pantin_ui::i18n::id_of). A text
whose words change with a number has an identifier of its own, written by hand in counts.ftl of
every language, with its plurals.
When a text is added or changed
python3 tools/i18n.py englishwriteslocales/en/pantin.ftlfrom the sources.python3 tools/i18n.py missingwrites, for each other language,missing.ftl.txt: the English of what it lacks.- Translate them in
tools/locales/<code>.py(a table from identifier to text), thenpython3 tools/i18n.py writewritespantin.ftlandcounts.ftlof each language.
crates/pantin-ui/tests/locales.rs fails when a text of the sources has no entry in English, when
two texts give the same identifier, when an entry of English is missing in another language, and when
a file does not read.
A new language
- Add it to
pantin_ui::i18n::Language: its name as it calls itself, its code, its files. - Copy
tools/locales/fr.pytotools/locales/<code>.py, translate every text and the plurals ofCOUNTS(Fluent knows the plural categories of each language), and add the code toOTHERSintools/i18n.py. python3 tools/i18n.py write <code>, thencargo test -p pantin-ui --test locales.
A language written with other letters than the Latin ones (Japanese, Chinese) needs a font that has them, carried by the application: the default fonts of egui do not.