Skip to content

Validate msgid_plural against msgstr[0] for languages with nplurals=1 - #1198

Merged
akx merged 1 commit into
python-babel:masterfrom
tomasr8:checker-one-plural
Nov 4, 2026
Merged

akx merged 1 commit into
python-babel:masterfrom
tomasr8:checker-one-plural

Conversation

@tomasr8

@tomasr8 tomasr8 commented Mar 9, 2025

Copy link
Copy Markdown
Member

The python format checker currently only validates msgid against the translation for languages with only one plural form. msgid_plural is not checked. For example, this:

msgid "foo"
msgid_plural "foo %s"
msgstr[0] "bar"

does not get flagged even though it should (missing %s in the translation).

Here's a real-world example:

#, python-format
msgid ""
"There is currently <strong><a href=\"%(url)s\">one active API "
"key</a></strong> in the system."
msgid_plural ""
"There are currently <strong><a href=\"%(url)s\">%(count)s active API "
"keys</a></strong> in the system."
msgstr[0] "系统中当前有 <strong> <a href=\"%(url)s\"> %(count)s 个活动 API 密钥 </a> </strong>。"

This translation should get flagged if it was missing the %(count)s placeholder since it appears in msgid_plural. it's not the case because only msgid is checked currently.

(This translation actually produces warnings as is, because the singular does not contain %(count)s, so perhaps an even better solution would be to only validate against the plural, but I'm not so sure about that)

@codecov

codecov Bot commented Mar 9, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (d02d6a8) to head (b6248b1).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1198   +/-   ##
=======================================
  Coverage   93.62%   93.63%           
=======================================
  Files          27       27           
  Lines        4960     4962    +2     
=======================================
+ Hits         4644     4646    +2     
  Misses        316      316           
Flag Coverage Δ
macos-14-3.10 92.66% <100.00%> (+<0.01%) ⬆️
macos-14-3.11 92.60% <100.00%> (+<0.01%) ⬆️
macos-14-3.12 92.86% <100.00%> (+<0.01%) ⬆️
macos-14-3.13 92.86% <100.00%> (+<0.01%) ⬆️
macos-14-3.14 92.84% <100.00%> (+<0.01%) ⬆️
macos-14-3.15 92.84% <100.00%> (+<0.01%) ⬆️
macos-14-3.8 92.53% <100.00%> (+<0.01%) ⬆️
macos-14-3.9 92.59% <100.00%> (+<0.01%) ⬆️
macos-14-pypy3.10 92.66% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.10 92.68% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.11 92.62% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.12 92.88% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.13 92.88% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.14 92.86% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.15 92.86% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.8 92.55% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.9 92.61% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-pypy3.10 92.68% <100.00%> (+<0.01%) ⬆️
windows-2022-3.10 92.67% <100.00%> (+<0.01%) ⬆️
windows-2022-3.11 92.61% <100.00%> (+<0.01%) ⬆️
windows-2022-3.12 92.87% <100.00%> (+<0.01%) ⬆️
windows-2022-3.13 92.87% <100.00%> (+<0.01%) ⬆️
windows-2022-3.14 92.85% <100.00%> (+<0.01%) ⬆️
windows-2022-3.15 92.85% <100.00%> (+<0.01%) ⬆️
windows-2022-3.8 92.65% <100.00%> (+<0.01%) ⬆️
windows-2022-3.9 92.61% <100.00%> (+<0.01%) ⬆️
windows-2022-pypy3.10 92.67% <100.00%> (+<0.01%) ⬆️

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.

@m-aciek m-aciek 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.

Looks good to me!

@akx
akx force-pushed the checker-one-plural branch from b38f7f0 to b6248b1 Compare November 4, 2026 09:19

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

Rebased. LGTM!

@akx
akx enabled auto-merge (squash) November 4, 2026 09:19
@codspeed

codspeed Bot commented Nov 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing tomasr8:checker-one-plural (b6248b1) with master (d02d6a8)

Open in CodSpeed

@akx
akx merged commit 6f1e45a into python-babel:master Nov 4, 2026
36 checks passed
@tomasr8
tomasr8 deleted the checker-one-plural branch November 4, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants