Translations¶
All source text is English. Russian is a translation catalogue next to the code. The plugin follows the QGIS interface language and falls back to English.
Files¶
- Python code with
tr("Apply"): the English original, which is also the key. ai_agent/translations/ai_agent_ru.ts: the catalogue. Edit only the translations.ai_agent/translations/ai_agent_ru.qm: the compiled file QGIS loads. Never edit it by hand.
A missing translation is harmless: tr() returns the English text.
Updating¶
After adding or changing a tr() string:
python3 tools/update_translations.py
It needs no dependencies. It extracts tr() and tr_n() literals by parsing
the AST, adds new entries to the .ts (existing translations stay) and
compiles the .qm with tools/qm.py. Fill in the empty <translation>
entries and run it again.
The stock QGIS tools are not used:
pylupdate5reads non-ASCII source as latin-1, missestr_nand writes the wrong context.lreleaseships only with the Qt tools, which neither QGIS nor a typical system has.tools/qm.pyproduces byte-identical output, pinned bytests/data/golden_ru.qm, whichlreleasebuilt once.
tests/test_i18n.py fails when an entry is untranslated, a placeholder ({0},
%n) is lost, or the catalogue drifts from the code.
Rules¶
tr()takes a literal:tr("Layer '{0}'").format(name), never an f-string.- Text a person reads (
summarize_call, everything inui/) goes throughtr(). Text the model reads (tool descriptions, schemas, errors) stays plain English, so a Russian QGIS does not send the model Russian schemas. - Plurals use
tr_n("%n step(s)", count); Russian has all three forms.
Adding a language¶
- Add the locale to
SUPPORTED_LOCALESinai_agent/i18n.pyand toLANGUAGE_NAMESincore/agent/prompts.py. - Add its plural rules to
NUMERUS_RULESintools/qm.py. The compiler refuses unknown languages. - Add the language to
LANGUAGESintools/update_translations.py, run it and translate the new.ts.