i18n: strings that bypass the block catalog (JS namespace, remote_exec, lti_form)

Open
#332 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
43/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, javascript, python

Research direction

Start with common/djangoapps/xblock_django/translation.py and the JS implementations for Video, Problem and Annotatable; the issue identifies xblock_problem/capa/safe_exec/remote_exec.py and xblock_lti's templates/lti_form.html as additional gaps. Check how blocks provide i18n_service and how namespaced JS catalogs are compiled. Done means the specified strings appear translated after pull_xblock_translations and compile_xblock_translations, including with built-in block code removed.

Written by the indexing model from the issue text.

Description

Follow-up to #329 (per-block translation catalogs, epic #241).

#329 gives each block its own catalog, but that catalog is only used when a string goes through the block's i18n service (XBlockI18nService in openedx-platform). Strings that skip the service are looked up in Django's global catalog. That catalog only has msgids from openedx-platform's own source, and the built-in copies of these strings are removed by the slash-n-burn PRs (openedx/openedx-platform#37819).

Gaps
  1. JS: no block defines i18n_js_namespace. compile_xblock_js_messages (common/djangoapps/xblock_django/translation.py) only builds a JS catalog for blocks that define it, and the blocks' JS calls the global gettext() / ngettext(). Video, Problem and Annotatable JS strings are translated today only because the platform's djangojs catalog has the same msgids from xmodule/js/src/ (about 55, 24 and 6 references).
    • Fix: set i18n_js_namespace on each block that has translatable JS, and call the namespaced gettext/ngettext in its JS. Each block's xmodule/js/src/ copy stays in the platform until its fix ships: Video (openedx/openedx-platform#38750), Problem (#38751), Annotatable (#38746).
  2. xblock_problem/capa/safe_exec/remote_exec.py imports django.utils.translation.gettext directly (3 codejail error messages). It's a module-level function with no block instance, so the translator has to be passed in.
  3. xblock_lti: templates/lti_form.html is rendered without i18n_service (block.py, render_django_template("templates/lti_form.html", ...)). openedx/openedx-platform#38747 deletes the platform copy.

Not affected: other templates (Word Cloud, Poll, Annotatable, PDF, LTI lti.html) already pass i18n_service. Video video.html and the Discussion templates render without it, but the platform keeps its copies, so their msgids stay in the global catalog. Problem templates go through render_to_string and have had no platform copy since before slash-n-burn. That gap already exists on master and is worth a separate look.

Done when
  • The Video, Problem and Annotatable JS strings, plus the two strings above, show up translated (e.g. in ar) after pull_xblock_translations and compile_xblock_translations, with the built-in block code removed.

Generated using Claude Code

Dominant language
JavaScript
Stars
0
Forks
19
Avg merge
1d 7h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openedx/xblocks-core

All issues in openedx/xblocks-core

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.