Adding a translation¶
All texts displayed by the interface live in pibooth/language.py, in the
DEFAULT dictionary keyed by two-letter language code. There is no gettext
and no .po file.
Keys¶
Every language section must define all of them. A missing key falls back to English at runtime and logs a warning.
Key |
Where it is displayed |
|---|---|
|
|
|
|
|
|
|
captures number choice — mind the singular and plural |
|
idem |
|
idem |
|
idem |
|
|
|
displayed during |
|
|
|
|
|
displayed when the user declines the print |
|
|
|
|
Adding a language¶
Insert a new section in
DEFAULT, in alphabetical order of the two-letter code users will put in[GENERAL][language].Copy the
enblock and translate every value, leaving the keys untouched.Keep the
\nline breaks. They are manual line wrapping for narrow areas of the screen, especiallyintro_printandprint_forget. Staying close to the number of lines and the line length used by the other languages avoids text overflowing its area.Add the language to the
Natural Language ::classifiers insetup.pyand to the feature list inREADME.rst.
Nothing else has to be registered: get_supported_languages() and the
settings menu pick the new section up automatically.
Things to know¶
Values are plain Python strings, so mind the quoting — an apostrophe forces double quotes, as in
"C'est parti !".The file is UTF-8, so accented and non-latin characters are fine provided the font can render them. The default fonts,
Amatic-BoldandAmaticSC-Regular, have a limited coverage: a language using Cyrillic, Greek or CJK characters also requires the user to set[WINDOW][font].Users can override any text in
~/.config/pibooth/translations.cfg, edited withpibooth --translate. Adding a key or a language is not destructive for existing installations: the defaults are merged into the user file.
Checking¶
tests/test_consistency.py checks that all sections define exactly the same
keys and that every language has its Natural Language :: classifier:
pytest tests/test_consistency.py
Then regenerate the translations file to see what users will get, without touching your own configuration:
pibooth --reset /tmp/piboothcfg
cat /tmp/piboothcfg/translations.cfg