Skip to content

feat(i18n): do-not-translate registry + MACHINE_READ marker standard#41651

Open
rusackas wants to merge 9 commits into
masterfrom
chore/i18n-skip-do-not-translate
Open

feat(i18n): do-not-translate registry + MACHINE_READ marker standard#41651
rusackas wants to merge 9 commits into
masterfrom
chore/i18n-skip-do-not-translate

Conversation

@rusackas

@rusackas rusackas commented Jul 2, 2026

Copy link
Copy Markdown
Member

SUMMARY

Establishes a standardized, cross-language do-not-translate convention for the translation catalogs, and teaches the AI backfill (backfill_po.py) to honor it.

Background. Some catalog entries must stay identical to the source or things break — icon names (bolt → the ⚡ Explore control icon), d3 enum values (step-after/step-before), API field names (error_message), SQL keywords, code constants, and example placeholders. A Russian translator had been marking these with a # Не переводить translator comment (thanks @PolinaFam, @goldjee!), but translator comments are per-catalog and don't propagate, and there is no official gettext "do not translate" flag. The AI backfill, which only checked for an empty msgstr, translated several of them (CodeAnt flagged them on #41649).

The standard. gettext extracted comments (#.) do propagate from messages.pot into every .po on pybabel update. So:

  • superset/translations/do-not-translate.txt — a canonical registry of do-not-translate msgids (one source of truth).
  • scripts/translations/apply_do_not_translate.py — stamps each registry msgid in messages.pot with a #. MACHINE_READ-DO_NOT_TRANSLATE extracted comment (format-preserving text edit; idempotent). Wired into babel_update.sh right after extraction, so pybabel update then propagates the marker to every catalog — consistent across languages.
  • backfill_po.py — loads the registry and honors the #. MACHINE_READ-DO_NOT_TRANSLATE marker (and the legacy # Не переводить translator comment, for back-compat), leaving these entries untranslated (source fallback).
  • UPDATING.md + contributing docs — document the new standard.

To mark a new string do-not-translate going forward: add its msgid to the registry. No per-catalog annotation needed.

The messages.pot in this PR already carries the 21 initial markers; they propagate to each .po the next time babel_update.sh / pybabel update runs.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — tooling + build.

TESTING INSTRUCTIONS

pytest tests/unit_tests/scripts/translations/backfill_po_test.py   # 36 pass
python scripts/translations/apply_do_not_translate.py               # idempotent; stamps messages.pot

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

The backfill only checked for an empty msgstr, so it filled entries a human
translator had deliberately left blank — e.g. the ru catalog's "# Не переводить"
(do-not-translate) markers on literal tokens. This translated strings that must
stay identical to the source: icon names (`bolt` -> the ⚡ Explore control
icon), d3 enum values (`step-after`/`step-before`), API field names
(`error_message`), SQL keywords, code constants, and example placeholders.

Add `_is_do_not_translate`, consulted when collecting untranslated entries. An
entry is skipped if its msgid is in the curated `DO_NOT_TRANSLATE` set (seeded
from the ru translator's markers; language-independent) or if it carries an
explicit do-not-translate translator comment in any catalog. Skipped entries are
reported and left untranslated (source-token fallback).

Adds unit tests for the curated set, translator-comment honoring (incl. the
Cyrillic marker), and the normal-entry pass-through.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dosubot dosubot Bot added the i18n:general Related to translations label Jul 2, 2026
@github-actions github-actions Bot added doc Namespace | Anything related to documentation risk:ci-script PR modifies scripts that execute in CI (supply chain risk) labels Jul 2, 2026
Comment thread scripts/translations/backfill_po.py Outdated
Comment thread scripts/translations/backfill_po.py Outdated
@netlify

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit def156d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a46a4e588884e0008a429cc
😎 Deploy Preview https://deploy-preview-41651--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review bito-code-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #502ef6

Actionable Suggestions - 1
  • scripts/translations/backfill_po.py - 1
    • Missing integration test for DNT filtering · Line 704-706
Review Details
  • Files reviewed - 2 · Commit Range: fb8af9c..fb8af9c
    • scripts/translations/backfill_po.py
    • tests/unit_tests/scripts/translations/backfill_po_test.py
  • Files skipped - 1
    • docs/developer_docs/contributing/howtos.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread scripts/translations/backfill_po.py Outdated
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.61%. Comparing base (8be255d) to head (3452af9).
⚠️ Report is 115 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41651      +/-   ##
==========================================
+ Coverage   64.56%   64.61%   +0.05%     
==========================================
  Files        2673     2685      +12     
  Lines      147634   148542     +908     
  Branches    34090    34209     +119     
==========================================
+ Hits        95314    95976     +662     
- Misses      50591    50799     +208     
- Partials     1729     1767      +38     
Flag Coverage Δ
hive 39.20% <ø> (+0.13%) ⬆️
mysql 57.88% <ø> (+0.20%) ⬆️
postgres 57.94% <ø> (+0.19%) ⬆️
presto 40.74% <ø> (+0.12%) ⬆️
python 59.33% <ø> (+0.18%) ⬆️
sqlite 57.52% <ø> (+0.19%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 2, 2026
@rusackas rusackas requested a review from sfirke as a code owner July 2, 2026 17:49
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Jul 2, 2026
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>
@rusackas rusackas force-pushed the chore/i18n-skip-do-not-translate branch from bd03dc7 to def156d Compare July 2, 2026 17:50
@rusackas rusackas changed the title feat(i18n): skip do-not-translate entries in backfill_po feat(i18n): do-not-translate registry + MACHINE_READ marker standard Jul 2, 2026
@rusackas

rusackas commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

cc @PolinaFam @goldjee — heads up, and thank you for curating the # Не переводить do-not-translate markers in the Russian catalog. 🙏 They were exactly the right signal, and they inspired this change.

Since gettext has no official "do not translate" flag and translator comments don't propagate across catalogs, this PR promotes that idea to a repo-wide standard: a superset/translations/do-not-translate.txt registry that stamps a #. MACHINE_READ-DO_NOT_TRANSLATE extracted comment into messages.pot, which then propagates to every language .po via pybabel update. The AI backfill and future tooling key off that marker.

Your existing # Не переводить comments are still honored for back-compat, so nothing breaks — but going forward (targeting 7.0) the extracted-comment marker + registry is the canonical way to mark a string do-not-translate. If you spot any tokens missing from the registry, just add the msgid there (or ping us) and it'll apply across all languages automatically.

@bito-code-review

bito-code-review Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #04d7fb

Actionable Suggestions - 0
Additional Suggestions - 1
  • scripts/translations/apply_do_not_translate.py - 1
    • NICE_TO_HAVE: Add unit tests for new tool · Line 1-106
      New translation tooling introduced at `scripts/translations/apply_do_not_translate.py` has no unit tests. Per project standards (adaptive rule [11730]), new tools require tests covering success paths, error scenarios, validation failures, and edge cases — e.g. registry-missing, registry-empty, idempotency of apply_markers(), and the _escape() formatter. The sibling script backfill_po.py has comprehensive coverage in tests/unit_tests/scripts/translations/backfill_po_test.py; follow that pattern.
Review Details
  • Files reviewed - 6 · Commit Range: fb8af9c..def156d
    • scripts/translations/backfill_po.py
    • tests/unit_tests/scripts/translations/backfill_po_test.py
    • scripts/translations/apply_do_not_translate.py
    • scripts/translations/babel_update.sh
    • superset/translations/do-not-translate.txt
    • superset/translations/messages.pot
  • Files skipped - 2
    • UPDATING.md - Reason: Filter setting
    • docs/developer_docs/contributing/howtos.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

rusackas pushed a commit that referenced this pull request Jul 3, 2026
…e tokens)

Follow-up to the review pass on the Persian catalog:

- 'Unpin' was translated 'اجرا کردن' ('execute'), which is wrong and
  inconsistent with the Unpin action family. Corrected to 'جداکردن' (detach),
  matching 'Unpin from the result panel'/'Unpin from top'.
- 'deck.gl Geojson', 'dttm', 'p1', 'p5', 'p95', 'p99' were identity
  passthroughs (msgstr == English). These are do-not-translate tokens (proper
  nouns, a datetime column abbreviation, percentile statistic labels), so they
  are emptied to fall back to the source literal, and added to the
  do-not-translate registry (#41651).

Left as-is: the 'Delayed (missed %s refresh)' plural has identical singular/
plural forms, which is correct Persian (nouns stay singular after a numeral;
18 of 39 existing plural entries do the same).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…late registry

These surfaced during the Persian review as identity passthroughs (machine
'translations' equal to the English source): the percentile statistic labels
p1/p5/p95/p99, the datetime column abbreviation dttm, and the proper-noun viz
name 'deck.gl Geojson'. They must stay literal, so add them to the registry;
apply_do_not_translate.py stamps the MACHINE_READ-DO_NOT_TRANSLATE marker into
messages.pot, which propagates to every catalog.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/backfill_po.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
@bito-code-review

bito-code-review Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1ec8cb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: def156d..f62560f
    • superset/translations/do-not-translate.txt
    • superset/translations/messages.pot
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

aminghadersohi and others added 2 commits July 2, 2026 21:14
Addresses code-review feedback on apply_do_not_translate.py:
- Strip each registry line before the blank/comment check, so trailing
  whitespace or an indented comment can't yield a msgid that fails to match the
  .pot (Critical).
- Fail fast with a non-zero exit when the registry file is missing, rather than
  silently producing catalogs without do-not-translate markers; an existing but
  empty registry remains a valid no-op (Major).
- Add explicit type annotations to the module-level constants.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Per review, add the explicit `Path` annotation on the module-level registry
path constant, matching the sibling constants.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/babel_update.sh Outdated
Comment thread scripts/translations/backfill_po.py
@bito-code-review

bito-code-review Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #32bbc8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f62560f..e495903
    • scripts/translations/apply_do_not_translate.py
    • scripts/translations/backfill_po.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

…po, annotate locals

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
Comment thread scripts/translations/apply_do_not_translate.py Outdated
@bito-code-review

bito-code-review Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #cfa57c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: e495903..bfead6a
    • scripts/translations/apply_do_not_translate.py
    • scripts/translations/babel_update.sh
    • scripts/translations/backfill_po.py
    • tests/unit_tests/scripts/translations/backfill_po_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

# "# Не переводить"). Honored so a human's deliberate decision is never
# overridden even if a msgid is missing from the registry.
_DO_NOT_TRANSLATE_COMMENT: re.Pattern[str] = re.compile(
r"machine_read-do_not_translate|не\s+переводить"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch the legacy Russian translator comment to use the standard marker? Or it should be on a follow up PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the ru catalog — all 21 # Не переводить msgids are already in the registry, so the standard marker lands there automatically on the next babel_update.sh run. Keeping catalog regeneration out of this PR; the legacy comments stay honored by backfill_po.py regardless.

@hainenber

Copy link
Copy Markdown
Contributor

I'd rather to have #. do-not-translate comment to be used as official gettext "do not translate" flag. Machines and humans alike would easily recognize the pattern, IMO.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/translations/apply_do_not_translate.py Outdated
@bito-code-review

bito-code-review Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #0422a3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: bfead6a..14abef6
    • scripts/translations/apply_do_not_translate.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2d4994

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 14abef6..3452af9
    • scripts/translations/apply_do_not_translate.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation i18n:general Related to translations i18n Namespace | Anything related to localization preset-io risk:ci-script PR modifies scripts that execute in CI (supply chain risk) size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants