Skip to content

fix(catalog): fix PYTHON_FORMAT regex false positives for percentage text - #1325

Open
goodluck-ry wants to merge 1 commit into
python-babel:masterfrom
goodluck-ry:error_to_warning
Open

fix(catalog): fix PYTHON_FORMAT regex false positives for percentage text#1325
goodluck-ry wants to merge 1 commit into
python-babel:masterfrom
goodluck-ry:error_to_warning

Conversation

@goodluck-ry

@goodluck-ry goodluck-ry commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #1268
Supersedes #1321

Hi @akx,

I've reverted the changes in frontend.py and refactored the PR to focus entirely on the regex rule in catalog.py.

The root cause of the false positive (such as '10% of' breaking builds) was that line 72 of catalog.py matched the space following '%' as a Python format flag in PYTHON_FORMAT. Removing the space flag from the regex prevents strings like '10% of' from being recognized as placeholders in the first place.

The original issue suggested downgrading errors from ERROR to WARNING. However, applying a downgrade in frontend.py would silently swallow real format mismatches. Fixing the regex at the source ensures that true syntax errors are still safely caught and exit with status 1, while the false positives are eliminated without touching error severity.

Trade-off note: Since explicit space-padded specifiers (like '% d') and text like '10% der' are textually identical at the static regex level, removing the space flag means '% d' won't be flagged. However, space-padded specifiers are extremely rare in translations compared to percentage text, making this a clean and pragmatically minimal fix.

I have updated the branch with corresponding tests for this case. Let me know what you think!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce compile translation checks from ERROR to WARNING

1 participant