Skip to content

Internationalization

The plugin follows OctoPrint's standard i18n: language follows the OctoPrint UI setting, no plugin-own switcher. Maintained catalogs: English (source strings) and German.

How strings flow

  • Templates: {{ _("...") }} (Jinja2, server side).
  • JavaScript: gettext("...") with _.sprintf for placeholders.
  • Extraction config: babel.cfg (python + jinja2 + javascript).

babel.cfg must stay OctoPrint-free

The jinja2 extraction section deliberately does not load octoprint.util.jinja.trycatch. pybabel extract truncates the output POT before extracting — if the extension import then fails (no OctoPrint in the environment), the empty POT wipes every translation as obsolete in the following update step.

Workflow

# extract + update + compile + copy into the package, in one go:
bash .githooks/check_translations_sync.sh

The pre-commit hook check-translations runs the same script and fails the commit once when catalogs changed (they are re-staged automatically — standard auto-fixer convention).

Compiled .mo files are tracked in git under both translations/ (source of truth) and octoprint_pandabranchplus/translations/ (what ships in the package), and are kept in sync by the script.

Adding a language

pybabel init --input-file=translations/messages.pot \
    --output-dir=translations --locale=<lang>

Translate the new translations/<lang>/LC_MESSAGES/messages.po, then run the sync script above.