Extract i18n strings from python_packages/ kolibri plugins
Overview
Kolibri's i18n recipes scan and compile only kolibri/ and packages/, writing to kolibri/locale/. Kolibri plugins migrated to python_packages/* carry their own user-facing strings that no recipe handles.
Complexity: Medium · Target branch: develop
Context
i18n-extract-frontendrunspnpm run makemessages, which callskolibri-i18n extract-messages.- It passes
--pluginFile build_tools/build_plugins.txt. - It adds
--namespace/--searchPathpairs forkolibri-coreandkolibri-common. - Output goes to
--localeDataFolder, defaultkolibri/locale. - That default is set in
[tool.kolibri.i18n]inpyproject.toml.
- It passes
i18n-extract-backendruns Djangomakemessagesfromcd kolibri.- Strings therefore land in
kolibri/locale.
- Strings therefore land in
i18n-uploaduploads viacrowdin.yml'ssource/translationpairs.- Every pair points under
kolibri/locale.
- Every pair points under
i18n-download-translationsdownloads translations from Crowdin.- It then runs
i18n-django-compilemessages(.po→.mo). - It then runs
create-message-files(CSV →<namespace>-messages.json).
- It then runs
build_plugins.txtlists onlykolibri.coreandkolibri.plugins.*.- So
python_packages/*plugins are excluded from extraction and message-file generation.
- So
webpack_json.pycomputes the correct per-plugin path (plugin_path/localefor non-kolibri.modules).- But the CLI discards it and writes to the single
--localeDataFolder.
- But the CLI discards it and writes to the single
- Django's
makemessagesnever consultswebpack_json.py.- It routes by app-level
locale/existence. - Missing that, it falls back to
LOCALE_PATHS(kolibri/locale).
- It routes by app-level
The change
Discover the plugins once by iterating python_packages/* and resolving each inner module. Both passes reuse that list.
CLI routing. Make extract-messages and create-message-files (and the other commands taking --localeDataFolder) honor each bundle's locale_data_folder instead of flattening to one folder.
_generatePathInfocarriesbundle.locale_data_folderonto each bundle-derived path entry.- Strip the
en/LC_MESSAGESsuffix thatwebpack_json.pyappends.
- Strip the
- Each namespace writes to its entry's folder.
--namespace/--searchPathentries fall back to--localeDataFolder.- These are the non-plugin
kolibri-core/kolibri-commonpackages.
- These are the non-plugin
Frontend — loop per plugin.
--pluginFileand--pluginscan't be combined.--pluginFiletakes precedence; the--pluginslist is ignored.- So each plugin needs its own call, separate from the Kolibri
--pluginFilerun. - For each discovered module with a
buildConfig.js, runextract-messages --plugins <module>. - Per-bundle routing sends each to its own
locale/. - Skip modules without a
buildConfig.js.--pluginson a backend-only plugin errors inwebpack_json.py.
- Don't add these plugins to
build_plugins.txt.- It also drives the webpack build.
Backend — loop per plugin.
- For each discovered module:
mkdir -p <module>/locale, thencd <module> && kolibri manage makemessages -- -l en …. - The
mkdiris load-bearing.- Without a pre-existing
locale/, Django writes the plugin's strings intokolibri/locale.
- Without a pre-existing
crowdin.yml.
- Add per-plugin
source/translationentries pointing at each plugin'slocale/. - Cover both CSV (frontend) and PO (backend).
Download.
i18n-django-compilemessages: add acd <module> && compilemessagespass per plugin.create-message-files: run per plugin to generate each plugin's<namespace>-messages.json.
Out of scope
platforms/* packages (kolibri-app, kolibri-installer-gnome, …) carry their own gettext-based i18n, not Kolibri's createTranslator/makemessages recipes. Handled once some platforms migrate in.
Acceptance criteria
- [ ]
extract-messages/create-message-fileswrite each bundle's strings to that bundle'slocale_data_folder. - [ ]
--localeDataFolderapplies only as the fallback for--searchPath/--namespaceentries. - [ ]
i18n-extract-frontendwrites eachbuildConfig.js-bearing plugin's frontend strings to that plugin's ownlocale/. - [ ]
build_plugins.txtis unchanged. - [ ]
i18n-extract-backendcreates each plugin'slocale/before runningmakemessages. - [ ] Each plugin's backend strings land in its own
locale/. - [ ] No plugin strings land in
kolibri/locale. - [ ]
i18n-uploaduploads pluginenstrings via per-plugincrowdin.ymlentries. - [ ]
i18n-download-translationswrites downloaded plugin translations into each plugin'slocale/. - [ ]
i18n-download-translationsgenerates each plugin's<namespace>-messages.json. - [ ]
i18n-download-translationscompiles each plugin's.mo.
Verified against the tree
kolibri-sentry-pluginis the onlypython_packages/*member with abuildConfig.js.- The frontend pass covers it today.
kolibri-oidc-client-pluginhas a backend string:gettext_lazy("Sign in with OpenID Connect").- It has no frontend bundle.
- The backend pass covers it today.
- With a pre-existing
locale/,cd <module> && makemessageswrites to<module>/locale/…/django.po.- Without it, the string leaks into
kolibri/locale/…/django.po.
- Without it, the string leaks into
AI usage
Used Claude Code to draft this issue. I drove scope and decisions.
Claude grounded each criterion by reading:
- the i18n Makefile recipes
- the
kolibri-i18nCLI webpack_json.pycrowdin.yml
Claude also verified empirically:
- the backend
makemessagesrouting - the frontend
locale_data_folderplumbing
Plan: Make Kolibri's i18n extract/compile/upload/download recipes route each python_packages/* plugin's user-facing strings to that plugin's own locale/ folder instead of flattening everything into kolibri/locale.
- [ ]
stripEnLcMessageshelper inutils.js - [ ] Per-namespace routing in
ExtractMessages.js - [ ] Per-namespace routing in
csvToJSON.js - [ ] Carry
locale_data_folderthroughcli.js_generatePathInfo - [ ] Phase 1 simplify pass
- [ ] Makefile plugin-discovery variables
- [ ]
i18n-extract-frontendloops buildConfig plugins - [ ]
i18n-extract-backendloops all plugins with pre-createdlocale/ - [ ] Phase 2 simplify pass
- [ ]
crowdin.ymlper-plugin source/translation entries - [ ] Compile and generate message files per plugin
- [ ] Phase 3 simplify pass
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output
Blocking decision needed on Task 10 (crowdin.yml per-plugin entries) before I can add the backend PO entry.
Done and unblocked: the sentry-plugin CSV entry is added. Frontend CSVs are namespace-prefixed (kolibri_sentry_plugin.main-messages.csv), so their basenames stay unique under preserve_hierarchy: false.
Blocked — the django.po basename collision. crowdin.yml sets preserve_hierarchy: false, so Crowdin keys each source by basename only. Django makemessages always emits django.po, so the oidc-client plugin's .../kolibri_oidc_client_plugin/locale/en/LC_MESSAGES/django.po would collide with kolibri's /kolibri/locale/en/LC_MESSAGES/django.po — one Crowdin file, strings merged on upload, both pulling the merged content on download. This corrupts both the plugin and kolibri backend catalogs. Config-level crowdin config validation cannot catch this (it validates YAML, not runtime dedup-by-basename).
Recommended mitigation (from the plan) — give the plugin PO a unique Crowdin filename via an explicit (non-wildcard) source + dest:
{"source": "/python_packages/kolibri-oidc-client-plugin/kolibri_oidc_client_plugin/locale/en/LC_MESSAGES/django.po", "dest": "/kolibri_oidc_client_plugin.django.po", "update_option": "update_as_unapproved", "translation": "/python_packages/kolibri-oidc-client-plugin/kolibri_oidc_client_plugin/locale/%locale_with_underscore%/LC_MESSAGES/django.po", "languages_mapping": *language_mapping}
dest renames the file in the Crowdin project only; the translation template still writes downloads back to the real local django.po, so compile/message-file steps are unaffected. (dest and wildcard sources are mutually exclusive, hence the explicit source.)
This introduces a new file name visible to translators in the live Crowdin project (kolibri_oidc_client_plugin.django.po) — a translation-infra decision, not a code one. Please confirm before I ship:
- Is
destthe accepted approach? - If not, do you prefer an alternative (Crowdin project-side path settings, a different
destnaming scheme, etc.)? - Or does the Crowdin project already handle same-basename files in a way that makes this moot?
Holding Task 10 Steps 2–3 (and the dependent Task 11 download verification) until this is resolved.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
I think your dest approach is an excellent way forward. Let's use that.