Skip to content

chore(i18n): harden backfill_po — full language-name map + resilient batch translation - #41644

Merged
rusackas merged 2 commits into
masterfrom
chore/i18n-tooling
Jul 1, 2026
Merged

chore(i18n): harden backfill_po — full language-name map + resilient batch translation#41644
rusackas merged 2 commits into
masterfrom
chore/i18n-tooling

Conversation

@rusackas

@rusackas rusackas commented Jul 1, 2026

Copy link
Copy Markdown
Member

SUMMARY

Improvements to scripts/translations/backfill_po.py (the AI translation backfill tool), split into two focused commits. This is the tooling companion to the per-language backfill PRs (#41608 de, #41609 es, #41612 lv, #41613 fi, #41640 sk, #41641 th, …); it will accumulate further hardening as the sweep surfaces issues.

1. Complete the LANGUAGE_NAMES map
The prompt falls back to the raw ISO code when a language is absent from LANGUAGE_NAMES (e.g. "Translate … into lv (lv)"), a weaker signal than a real language name. Adds the six present catalogs that were missing: cs (Czech), fi (Finnish), lv (Latvian), ro (Romanian), sr_Latn (Serbian, Latin script), th (Thai). The map now covers every locale directory under superset/translations.

2. Resilient batch translation (bisect + plain-text fallback)
A source msgid containing a literal double-quote (e.g. "Exact match") can make the model echo unescaped quotes into its JSON response, so json.loads fails and the entire batch is discarded — losing up to --batch-size good translations per offending entry. (Observed live on the Slovak catalog: 3 such strings sank ~100 translations across batches.)

_resilient_translate wraps translate_batch: on a JSON parse failure it bisects the batch and recurses, isolating the offenders; a lone entry that still fails falls back to a plain-text prompt (_translate_single_plaintext) that avoids the JSON envelope entirely. CLI failures (RuntimeError) still propagate to the existing per-batch handler. Verified live on the Thai catalog — the same 3 quote-bearing entries were recovered automatically with zero batch loss.

Adds 4 unit tests: passthrough, bisect-and-fallback with correct index remapping, dropped-entry-on-fallback-failure, and RuntimeError propagation.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — internal tooling.

TESTING INSTRUCTIONS

pytest tests/unit_tests/scripts/translations/backfill_po_test.py

(31 tests pass.)

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

aminghadersohi and others added 2 commits June 30, 2026 23:35
The backfill prompt falls back to the raw ISO code when a language is absent
from LANGUAGE_NAMES (e.g. "Translate ... into lv (lv)"), which gives Claude a
weaker signal than a real language name. Add the six present catalogs that were
missing: cs (Czech), fi (Finnish), lv (Latvian), ro (Romanian),
sr_Latn (Serbian, Latin script), and th (Thai). LANGUAGE_NAMES now covers every
locale directory under superset/translations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A source msgid containing a literal double-quote (e.g. `"Exact match"`) can
make the model echo unescaped quotes into its JSON response, so `json.loads`
fails and the ENTIRE batch is discarded — losing up to `--batch-size` good
translations per poison entry.

`_resilient_translate` wraps `translate_batch`: on a JSON parse failure
(ValueError) it bisects the batch and recurses, so only the offending entries
are isolated; a lone entry that still fails falls back to a plain-text prompt
(`_translate_single_plaintext`) that avoids the JSON envelope entirely. CLI
failures (RuntimeError) still propagate to the existing per-batch handler.

Adds four unit tests covering passthrough, bisect-and-fallback with correct
index remapping, dropped-entry-on-fallback-failure, and RuntimeError
propagation.

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

bito-code-review Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e1ea99

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f9ce7f9..732bcd8
    • 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

@github-actions github-actions Bot added the risk:ci-script PR modifies scripts that execute in CI (supply chain risk) label Jul 1, 2026
@dosubot dosubot Bot added the i18n:general Related to translations label Jul 1, 2026
@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 732bcd8
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a459e6aa22fbd00084d77b8
😎 Deploy Preview https://deploy-preview-41644--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.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.42%. Comparing base (3e88b48) to head (732bcd8).
⚠️ Report is 23 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #41644    +/-   ##
========================================
  Coverage   64.42%   64.42%            
========================================
  Files        2668     2670     +2     
  Lines      147181   147395   +214     
  Branches    33946    33985    +39     
========================================
+ Hits        94815    94956   +141     
- Misses      50649    50707    +58     
- Partials     1717     1732    +15     
Flag Coverage Δ
hive 39.06% <ø> (-0.04%) ⬇️
mysql 57.68% <ø> (+0.02%) ⬆️
postgres 57.74% <ø> (+0.02%) ⬆️
presto 40.61% <ø> (-0.05%) ⬇️
python 59.15% <ø> (+0.01%) ⬆️
sqlite 57.33% <ø> (-0.03%) ⬇️
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.

@rusackas
rusackas merged commit 8be255d into master Jul 1, 2026
63 checks passed
@rusackas
rusackas deleted the chore/i18n-tooling branch July 1, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n:general Related to translations 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