feat(i18n): standardize do-not-translate via registry + .pot marker

Replace the hardcoded DO_NOT_TRANSLATE set with a canonical registry file
(superset/translations/do-not-translate.txt) and a propagating, gettext-native
marker, so do-not-translate status is consistent across every catalog and
maintained in one place.

- superset/translations/do-not-translate.txt: the msgid registry.
- scripts/translations/apply_do_not_translate.py: stamps each registry msgid in
  messages.pot with a `#. MACHINE_READ-DO_NOT_TRANSLATE` extracted comment via
  format-preserving text edit (idempotent). Wired into babel_update.sh after
  extraction; `pybabel update` then propagates the marker into every .po.
- backfill_po.py: loads the registry (single source of truth) and honors the
  `#. MACHINE_READ-DO_NOT_TRANSLATE` marker (extracted comment) as well as the
  legacy `# Не переводить` translator comment, in the extracted OR translator
  comment.
- UPDATING.md + howtos: document the new standard.

There is no official gettext "do not translate" flag; an extracted comment
propagated from the .pot is the closest native, cross-language mechanism.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Amin Ghadersohi
2026-07-02 10:43:01 -07:00
parent 68186a0485
commit def156df51
8 changed files with 243 additions and 46 deletions

View File

@@ -342,10 +342,15 @@ uses Claude AI to generate draft translations for any missing entries. All
AI-generated strings are marked `#, fuzzy` and tagged with an attribution
comment so that human reviewers know they need to be checked before merging.
The script never touches entries that must stay literal — msgids in its curated
`DO_NOT_TRANSLATE` set (icon names, enum values, SQL keywords, API field names,
example placeholders) and any entry carrying an explicit do-not-translate
translator comment (e.g. the ru catalog's `# Не переводить`). Those are left
The script never touches entries that must stay literal — icon names, enum
values, SQL keywords, API field names, and example placeholders. These are
registered in `superset/translations/do-not-translate.txt`;
`scripts/translations/apply_do_not_translate.py` stamps them in `messages.pot`
with a `#. MACHINE_READ-DO_NOT_TRANSLATE` extracted comment (run automatically
from `babel_update.sh`), which `pybabel update` then propagates to every
catalog. To mark a new string do-not-translate, add its msgid to the registry.
The backfill also honors that marker and any legacy do-not-translate translator
comment (e.g. the `ru` catalog's `# Не переводить`), leaving such entries
untranslated so they fall back to the source token.
#### Prerequisites