Skip to content

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

  1. Create the locale directory:

    mkdir -p src/geotui/i18n/locales/fr/LC_MESSAGES
    

  2. Initialise the .po file from the template:

    msginit -i src/geotui/i18n/messages.pot \
            -o src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.po \
            -l fr
    

  3. Edit geotui.po and add translations for each msgid

  4. Compile the .mo file:

    msgfmt -o src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.mo \
           src/geotui/i18n/locales/fr/LC_MESSAGES/geotui.po
    

  5. Register the language code in src/geotui/i18n/__init__.py

Updating Translations

When you add new user-facing strings:

  1. Extract strings from source:

    xgettext -o src/geotui/i18n/messages.pot \
             --language=Python \
             src/geotui/**/*.py
    

  2. Merge into existing .po files:

    msgmerge -U src/geotui/i18n/locales/pt/LC_MESSAGES/geotui.po \
             src/geotui/i18n/messages.pot
    

  3. Translate new entries (marked #, fuzzy or empty msgstr)

  4. Compile updated .mo files:

    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_LANG before 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

Made with ❤ by Kartoza | Donate! | GitHub