Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46580 +/- ##
=======================================
Coverage 86.08% 86.08%
=======================================
Files 3140 3140
Lines 219075 219083 +8
Branches 51919 51921 +2
=======================================
+ Hits 188591 188601 +10
+ Misses 27055 27054 -1
+ Partials 3429 3428 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aminghadersohi
left a comment
There was a problem hiding this comment.
The new detection reproduces the committed catalogs, but backfill_po.py still re-adds the flag to the same entries.
rusackas
left a comment
There was a problem hiding this comment.
Thanks @antalotec, detecting these beats growing the list by hand. +1 to @aminghadersohi's backfill_po.py point though, since the weekly backfill would put python-format right back on the new labels. Maybe normalize_catalog could share the same check?
GitHub shows conflicts now too, so it'll need a rebase.
…them
Labels such as "% of" parse as a valid %-format directive with a space
flag ("% o"), so Babel flags them python-format, and msgfmt then fatals
on any translation whose next letter is not a conversion character: the
German "% von" reads as "% v", and the Chinese translations of all
eight labels carry no directive at all. babel_update.sh and
backfill_po.py each unflag three of these by name, so the other five
labels and three help texts mentioning "% of column" stay flagged, and
every backfill re-flags what a catalog fixed by hand.
Move the check into scripts/translations/unflag_pseudo_format.py and
share it: an entry is unflagged when every directive Babel finds in its
msgid and msgid_plural carries the space flag. Real placeholders never
do, and %% only appears in strings that are formatted, so a string that
holds either stays flagged. babel_update.sh runs the script and stops if
it fails; backfill_po.normalize_catalog uses the same check. Apply it to
the template and the catalogs; only "#," lines change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
167ac6e to
8ceb2c2
Compare
|
Closing this as superseded by #46320, which landed the same fix (a shared check for |
SUMMARY
Some UI labels parse as an accidentally valid %-format directive: a space flag plus a conversion character, so
"% of"reads as% o(octal). Babel flags thempython-format, andmsgfmt --checkthen fatals on translations that don't keep that shape: German"% von"reads as% v, and the Chinese translations of these labels (#46129) carry no directive at all.babel_update.shandbackfill_po.pyeach unflag three of these labels by name (% calculation,% of parent,% of total). Five more labels (% of,% of column,% of column total,% of grand total,% of row total) and three help texts mentioning "% of column" have the same shape and stay flagged. Two recent catalog PRs (#45931, #45674) unflagged them by hand, and every backfill run flags them again, becausenormalize_catalogonly knows the three listed labels.This PR moves the check into
scripts/translations/unflag_pseudo_format.pyand shares it between both writers. An entry is unflagged when every directive Babel's ownPYTHON_FORMATregex finds in its msgid (and msgid_plural) carries the space flag. Real placeholders (%s,%d,%(name)s) never do, and%%only appears in strings that are formatted, so a string holding either keeps the flag.babel_update.shruns the script afterpybabel updateand stops if it fails (|| exit 1). The script only rewrites#,lines, so canonical wrapping is untouched, and it handles msgids that pybabel folds across lines.backfill_po.normalize_cataloguses the sameis_pseudo_formatcheck, so a backfill no longer re-flags these entries.#,lines (8 per catalog, 3 initand none inpl, which were already fixed by hand, plus 11 inmessages.pot).Measured on master
d2598e2:msgfmt --check(30 catalogs)msgfmt --check --use-fuzzynormalize_catalogon the fixed catalogs, thenmsgfmt --checkThe 3 that remain are unrelated: Italian plurals whose singular form drops the
%s.Nothing users see changes: the flag is read by tooling only. The frontend JSON (
po2json-cli.js) and the compiled.mofiles (pybabel compile --use-fuzzy) come out byte-identical to master for all 30 catalogs.TESTING INSTRUCTIONS
pytest tests/unit_tests/scripts/translations/.unflag_pseudo_format_test.pycovers the detection (accidental labels, real placeholders, mixed strings, plurals,%%) and the rewrite: only#,lines change, the step is idempotent, andmsgfmt --checkfails before and passes after.babel_update_test.pyruns the real script end to end: the template and catalogs come out unflagged, a real placeholder keeps its flag, and a failing unflag step makes the script exit non-zero.backfill_po_test.pychecks thatnormalize_catalogunflags the same labels, including a long msgid, and keeps real placeholders and plurals flagged.msgfmt --check -o /dev/null superset/translations/zh/LC_MESSAGES/messages.pofails on master (8 fatal) and passes here../scripts/translations/babel_update.shon master and on this branch leaves only#,lines differing.ADDITIONAL INFORMATION
Developed at MYSPHERA, S.L.