Skip to content

fix(i18n): stop flagging literal "% of" labels as python-format - #46320

Merged
rusackas merged 3 commits into
apache:masterfrom
schizophrenicmaniac:fix/46304-incorrect-labels-in-pot-files
Nov 26, 2026
Merged

rusackas merged 3 commits into
apache:masterfrom
schizophrenicmaniac:fix/46304-incorrect-labels-in-pot-files

Conversation

@schizophrenicmaniac

Copy link
Copy Markdown
Contributor

SUMMARY

Babel marks a message python-format whenever the msgid contains something that looks like a %-directive. Labels such as "% of row total" match by accident: % o reads as a space flag plus the o conversion. Nothing ever %-formats these strings, but msgfmt then rejects translations that don't reproduce the fake directive. babel_update.sh and normalize_catalog() in backfill_po.py both cleared the flag, but only for a hardcoded list of three labels ("% calculation", "% of parent", "% of total"), so every label added later ("% of", "% of column", "% of column total", "% of grand total", "% of row total") and the three conditional-formatting tooltips that mention "% of column" kept the wrong flag.

This replaces the list with one check in a small new script, scripts/translations/literal_percent.py. A message counts as literal when every directive Babel finds is a % followed by a space and a word. Anything with a real placeholder (%(name)s, %s) keeps its flag. babel_update.sh runs the script after pybabel update, where the old heredoc ran, and backfill_po.py imports the same function, so the two places can't drift apart again. The script rewrites only the #, flag lines. It reads msgids wrapped over several lines, so the long tooltips in the 76-column .po files are covered as well.

I also ran it over messages.pot and all language catalogs. The only changes are the flag lines of the 5 labels and 3 tooltips from the issue, with existing fuzzy flags kept.

"Contains text (ILIKE %x%)" and "Ends with (ILIKE %x)" are also flagged python-format, but %x is a real directive shape and not the "% of" pattern, so I left them out of this PR.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable, no UI change.

TESTING INSTRUCTIONS

  1. pytest tests/unit_tests/scripts/translations/literal_percent_test.py tests/unit_tests/scripts/translations/backfill_po_test.py tests/unit_tests/scripts/translations/babel_update_test.py
  2. grep -n -B1 'msgid "% of' superset/translations/messages.pot shows #, no-python-format on every "% of ..." label.
  3. python scripts/translations/literal_percent.py on this branch changes nothing. On master it fixes the entries listed in the issue.
  4. With gettext installed, msgfmt -c -o /dev/null superset/translations/fr/LC_MESSAGES/messages.po no longer reports format mismatches for these entries once they have translations.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Incorrect labels in POT files #46304
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 1c41e787ea94

@github-actions github-actions Bot added i18n Namespace | Anything related to localization i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:german Translation related to German language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language i18n:dutch i18n:slovak i18n:slovenian i18n:ukrainian i18n:portuguese labels Nov 18, 2026

@aminghadersohi aminghadersohi 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.

One edge case in the literal-percent check, inline.

Comment thread scripts/translations/literal_percent.py Resolved
@sadpandajoe sadpandajoe added the review:checkpoint Last PR reviewed during the daily review standup label Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.05%. Comparing base (41538e6) to head (1c41e78).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46320      +/-   ##
==========================================
+ Coverage   86.04%   86.05%   +0.01%     
==========================================
  Files        3138     3138              
  Lines      218690   218858     +168     
  Branches    51771    51799      +28     
==========================================
+ Hits       188166   188335     +169     
+ Misses      27096    27094       -2     
- Partials     3428     3429       +1     
Flag Coverage Δ
hive 33.69% <ø> (-0.03%) ⬇️
mysql 51.47% <ø> (+<0.01%) ⬆️
postgres 51.49% <ø> (+<0.01%) ⬆️
presto 35.37% <ø> (-0.03%) ⬇️
python 88.58% <ø> (+0.01%) ⬆️
sqlite 51.18% <ø> (+<0.01%) ⬆️
unit 84.13% <ø> (+0.02%) ⬆️

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.

@sadpandajoe sadpandajoe removed the review:checkpoint Last PR reviewed during the daily review standup label Nov 19, 2026

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @schizophrenicmaniac, LGTM! Nice to see the hardcoded list go away in favor of one shared check.

@rusackas
rusackas force-pushed the fix/46304-incorrect-labels-in-pot-files branch from 55eead8 to cbd3318 Compare November 25, 2026 01:37
@rusackas rusackas added the merge-if-green If approved and tests are green, please go ahead and merge it for me label Nov 25, 2026
schizophrenicmaniac and others added 3 commits November 25, 2026 12:57
…ce the rebase

Run scripts/translations/literal_percent.py over the catalogs so the
committed-catalog guard passes against current master.

Co-Authored-By: Evan Rusackas <evan@preset.io>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rusackas
rusackas force-pushed the fix/46304-incorrect-labels-in-pot-files branch from cbd3318 to 1c41e78 Compare November 26, 2026 17:06
@rusackas
rusackas merged commit 3758941 into apache:master Nov 26, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n:arabic i18n:brazilian i18n:catalan i18n:chinese Translation related to Chinese language i18n:czech i18n:dutch i18n:finnish i18n:french Translation related to French language i18n:german Translation related to German language i18n:italian Translation related to Italian language i18n:japanese Translation related to Japanese language i18n:korean Translation related to Korean language i18n:latvian i18n:maori i18n:persian i18n:portuguese i18n:romanian i18n:russian Translation related to Russian language i18n:serbian i18n:serbian-latin i18n:slovak i18n:slovenian i18n:spanish Translation related to Spanish language i18n:tamil i18n:thai i18n:traditional-chinese i18n:turkish i18n:ukrainian i18n Namespace | Anything related to localization merge-if-green If approved and tests are green, please go ahead and merge it for me risk:ci-script PR modifies scripts that execute in CI (supply chain risk) size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect labels in POT files

4 participants