Repository navigation
Conversation
11d8dd9 to
8f4fcc0
Compare
7e81202 to
cf7cd0f
Compare
openedx-platform looks up xblock translations by module name (translations/*/<module_name>/conf/locale), so a single combined catalog can't be matched to the blocks. Write one django.po per block under <module_name>/conf/locale/ instead, mirroring openedx/xblocks-extra#35. The compile/dummy/validate/pull/push targets and the translations tox env relied on the old src/ text.po layout, so they are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cf7cd0f to
90d0368
Compare
Extraction only needs conf/locale/, and OEP-58 syncs through the Transifex GitHub App, so the client .tx/config (which pointed at the no-longer-produced text.po) is not needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
The per-block layout looks right to me: xblock_<name>/conf/locale matches the platform's atlas lookup translations/*/{module_name}/conf/locale.
Some strings will still be read from the platform catalog. The per-block catalog is only used through the block's i18n service. Strings that skip it go to Django's global catalog, which only has msgids from openedx-platform's own source:
- JS. No block defines
i18n_js_namespace, socompile_xblock_js_messages(xblock_django/translation.py) never compiles a JS catalog for them, and the blocks' JS calls the globalgettext(). Video, Problem and Annotatable JS is translated today only because the platform's djangojs catalog still has the same msgids fromxmodule/js/src/. Those copies go away with the built-in blocks. - Python and templates (smaller).
xblock_problem/capa/safe_exec/remote_exec.pycalls Django'sgettextdirectly. LTI'slti_form.htmlis rendered withouti18n_service.
The fix (i18n_js_namespace plus namespaced JS calls, and the i18n service at those two spots) is block code, so I've opened #332 to track it outside this PR.
What counts as "confirmed working"? I'd suggest: the xblock_* catalogs exist in openedx-translations, and pull_xblock_translations produces non-empty ar/es_419 catalogs for them.
Generated using Claude Code
| echo "Extracting translations for $$xblock..."; \ | ||
| module_name=$$(basename $$xblock); \ | ||
| echo "Extracting translations for $$module_name..."; \ | ||
| cd $$xblock && i18n_tool extract --no-segment; \ |
There was a problem hiding this comment.
If i18n_tool extract fails for one block, the loop carries on and make exits 0, so the daily openedx-translations job could commit a partial set of source files. Maybe cd $$xblock && i18n_tool extract --no-segment || exit 1; \?
Generated using Claude Code
The loop ran as one shell command whose exit code came from its last statement, so a failed i18n_tool, msgcat or mv was swallowed and make exited 0. The daily openedx-translations job could then commit a partial set of source files. Run the loop under set -e, with each step as its own statement so set -e catches it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The loop ran as one shell command whose exit code came from its last statement, so a failed i18n_tool, msgcat or mv was swallowed and make exited 0. The daily openedx-translations job could then commit a partial set of source files. Run the loop under set -e, with each step as its own statement so set -e catches it. Same fix as openedx/xblocks-core#329. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@irfanuddinahmad this is ready for a second pass. Your comment on the extract loop is fixed in cba03eb, and all checks are green. |
Ticket: Closes xblocks-core#242 (epic: xblocks-core#241)
This follows the same approach as xblocks-extra#35. The companion PR is openedx-translations#85196, and the docs update is xblocks-core#331.
Summary
openedx-platform looks up XBlock translations by module name (
i18n_api.py), so it can't match the old single combined catalog to the blocks.make extract_translationsnow writes onedjango.poper block toxblock_<name>/conf/locale/en/LC_MESSAGES/at the repo root.translationstox env. They relied on the oldtext.polayout, and no CI workflow runs them.extract_translationsnow stops and exits non-zero if any block fails, so the daily job can't commit a partial set of source files..gitignore:*.po→**/conf/locale/**/LC_MESSAGES/*.conf/locale/config.yamlnow lists only the source locale (en), matching openedx-platform and xblocks-extra.dummy_localesis removed because nothing reads it.xblock_pdfgetsconf/locale/config.yamland__init__.py. Without them, extraction skipped it.Translation flow
This is the OEP-58 flow, as described in Enabling Translations on a New Repo:
make extract_translations. Its python-monorepo job then commits each block's source file totranslations/xblocks-core/xblock_<name>/conf/locale/en/.make pull_xblock_translationsruns atlas withtranslations/*/<module_name>/conf/locale:<module_name>for each installed XBlock and compiles the result.For example, Arabic for the problem block lands at:
The extracted blocks show translated strings today only because of a fallback. Their own catalog is missing, so Django uses the edx-platform catalog, which still has the same msgids from the built-in
xmoduleblocks (see xblocks-core#241).xblock_problemvsxmodule), so the atlas glob clash fixed in openedx-translations#73194 doesn't apply.xblock_*catalogs exist in openedx-translations, andmake pull_xblock_translations(inlms-shell) produces non-emptyar/es_419catalogs for them.i18nservice and are still read from the platform catalog: the Video, Problem and Annotatable JS (no block definesi18n_js_namespace),xblock_problem/capa/safe_exec/remote_exec.pyand LTI'slti_form.html. A per-block catalog doesn't cover them.How to test
uv run --with edx-i18n-tools make extract_translations. This needs GNU gettext.xblock_*/conf/locale/en/LC_MESSAGES/django.po.uv run --with edx-i18n-tools django-admin compilemessages --locale ensucceeds.Local result: all 9 blocks were extracted (
xblock_problem215 msgids,xblock_discussion131,xblock_video129, …), and compilation succeeded.🤖 Generated with Claude Code