Internationalisation
Supported Languages
| Code | Language | Status |
|---|---|---|
en |
English | Default |
pt |
Portuguese | Complete |
es |
Spanish | Complete |
How It Works
GeoTUI uses Python's gettext module for internationalisation. All user-facing strings are wrapped in the _() function:
from geotui.i18n import _
label = _("No workspaces found")
message = _("Publishing {count} layers").format(count=5)
File Structure
src/geotui/i18n/
├── __init__.py # _() function and language switching
├── messages.pot # Translation template (source of truth)
└── locales/
├── pt/
│ └── LC_MESSAGES/
│ ├── geotui.po # Portuguese translations (editable)
│ └── geotui.mo # Portuguese compiled (binary)
└── es/
└── LC_MESSAGES/
├── geotui.po # Spanish translations (editable)
└── geotui.mo # Spanish compiled (binary)
Adding a New Language
-
Create the locale directory:
mkdir -p src/geotui/i18n/locales/fr/LC_MESSAGES -
Initialise the
.pofile from the template:msginit -i src/geotui/i18n/messages.pot \ -o src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.po \ -l fr -
Edit
geotui.poand add translations for eachmsgid -
Compile the
.mofile:msgfmt -o src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.mo \ src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.po -
Register the language code in
src/geotui/i18n/__init__.py
Updating Translations
When you add new user-facing strings:
-
Extract strings from source:
xgettext -o src/geotui/i18n/messages.pot \ --language=Python \ src/geotui/**/*.py -
Merge into existing
.pofiles:msgmerge -U src/geotui/i18n/locales/pt/LC_MESSAGES/geotui.po \ src/geotui/i18n/messages.pot -
Translate new entries (marked
#, fuzzyor emptymsgstr) -
Compile updated
.mofiles:msgfmt -o src/geotui/i18n/locales/pt/LC_MESSAGES/geotui.mo \ src/geotui/i18n/locales/pt/LC_MESSAGES/geotui.po
Runtime Language Switching
Users can switch languages in two ways:
- Ctrl+L — cycles through available languages at runtime
- Environment variable — set
GEOTUI_LANGbefore launching:GEOTUI_LANG=pt geotui
Guidelines for Translators
- Keep translations concise — TUI space is limited
- Preserve
{variable}placeholders exactly as they appear - Test your translations in the TUI to check for truncation
- Use formal register where appropriate