DevelopersContribute

Translate Liana

Edit the catalogs that hold the interface text, add an entry or a language, and keep every catalog in sync before you push.

Liana's interface text lives in one catalog per language, in the liana-i18n/i18n/ folder of the repository Requires Liana 16.0+. English is the source.

Liana 16.0 introduced the catalogs

Work on the master branch, or on v16.0 or a later tag. Liana 15.0 has no liana-i18n crate.

Read a catalog

Each catalog is a .lang file, such as liana_fr.lang, that names its language in its header:

# Language: Français

The English catalog, liana_en.lang, gives each entry an id and its text:

common-no-label => "No label"

The other catalogs keep the English text next to the translation:

common-no-label => "No label" => "Aucune étiquette"
  • NONE: The bare word, without quotes, marks an entry nobody has translated yet. Liana shows the English text for it.
  • Long entries: Write the id on its own line, each => "…" on the lines that follow, and end the entry with ;;.
  • Line breaks: Write \n inside a value.

Add an entry

$ cargo run -p liana-i18n-toolbox -- add-entry coins-label "Label"
synced: liana-i18n/i18n/liana_fr.lang
synced: liana-i18n/i18n/liana_it.lang
synced: liana-i18n/i18n/liana_pt-BR.lang
synced: liana-i18n/i18n/liana_pt-PT.lang
added 'coins-label'

The tool adds the English value to liana_en.lang and marks the entry NONE in every other catalog.

Add a language

Pass the locale, then the name the language picker shows, written in that language:

$ cargo run -p liana-i18n-toolbox -- add-lang de Deutsch
created liana-i18n/i18n/liana_de.lang
Deutsch is picked up by the next build

The new catalog starts with every entry at NONE. After the next build, German appears in the language picker. Nothing else needs editing.

Change the English text of an entry

Edit the value in liana_en.lang only, for example from "No label" to "No label yet". The other catalogs no longer match, so cargo build fails, and so does the check that CI runs:

$ cargo run -p liana-i18n-toolbox -- sync --verify
outdated: liana-i18n/i18n/liana_fr.lang
outdated: liana-i18n/i18n/liana_it.lang
outdated: liana-i18n/i18n/liana_pt-BR.lang
outdated: liana-i18n/i18n/liana_pt-PT.lang

Run sync to rewrite the other catalogs:

$ cargo run -p liana-i18n-toolbox -- sync
synced: liana-i18n/i18n/liana_fr.lang
synced: liana-i18n/i18n/liana_it.lang
synced: liana-i18n/i18n/liana_pt-BR.lang
synced: liana-i18n/i18n/liana_pt-PT.lang

In each other catalog, the entry's translation becomes NONE, with the old one kept as a note:

common-no-label => "No label yet" => NONE # "Aucune étiquette"

Translate an entry

In the catalog of your language, find each NONE and replace it with your translation, in double quotes. Delete the note that may follow it, such as # "Aucune étiquette", because the build rejects a translated entry that keeps one:

liana_fr.lang
common-no-label => "No label yet" => "Pas encore d'étiquette"

Check a translation in Liana

In a liana-gui that you built from your branch, select the language under Language in Settings > General. Liana switches at once. The launcher shows the same picker in its top bar.

Settings > General in Liana 16.0, with the Language picker open on English, Français, Italiano, Português (Brasil) and Português (Portugal).
The Language picker lists each catalog under the name its header gives.

Check the catalogs before you push

CI runs these two checks on the tip of your branch:

cargo run -p liana-i18n-toolbox -- sync --verify
cargo run -p liana-i18n-toolbox -- check-ids
  • sync --verify: Fails on a catalog that no longer matches the English one.
  • check-ids: Fails on an id that the code uses but the English catalog lacks, and on an id in the catalog that nothing uses.

When they pass, sync --verify prints catalogs are synced with liana_en.lang and check-ids prints i18n id check passed. Also run this test, which fails on a catalog it cannot read:

cargo test -p liana-i18n

Next steps