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

オープン
#332 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
43/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
django, javascript, python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
JavaScript
スター
0
フォーク
19
平均マージ
1日 7時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openedx/xblocks-core のほかの issue

openedx/xblocks-core の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。