pantin

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

  1. python3 tools/i18n.py english writes locales/en/pantin.ftl from the sources.
  2. python3 tools/i18n.py missing writes, for each other language, missing.ftl.txt: the English of what it lacks.
  3. Translate them in tools/locales/<code>.py (a table from identifier to text), then python3 tools/i18n.py write writes pantin.ftl and counts.ftl of 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

  1. Add it to pantin_ui::i18n::Language: its name as it calls itself, its code, its files.
  2. Copy tools/locales/fr.py to tools/locales/<code>.py, translate every text and the plurals of COUNTS (Fluent knows the plural categories of each language), and add the code to OTHERS in tools/i18n.py.
  3. python3 tools/i18n.py write <code>, then cargo 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.