Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Mar 9, 2025

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)

Copy link

codecov bot commented Mar 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.69%. Comparing base (2b93a4a) to head (b38f7f0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1198   +/-   ##
=======================================
  Coverage   91.69%   91.69%           
=======================================
  Files          27       27           
  Lines        4694     4696    +2     
=======================================
+ Hits         4304     4306    +2     
  Misses        390      390           
Flag Coverage Δ
macos-14-3.10 90.73% <100.00%> (+<0.01%) ⬆️
macos-14-3.11 90.67% <100.00%> (+<0.01%) ⬆️
macos-14-3.12 90.88% <100.00%> (+<0.01%) ⬆️
macos-14-3.13 90.88% <100.00%> (+<0.01%) ⬆️
macos-14-3.8 90.60% <100.00%> (+<0.01%) ⬆️
macos-14-3.9 90.66% <100.00%> (+<0.01%) ⬆️
macos-14-pypy3.10 90.73% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.10 90.75% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.11 90.69% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.12 90.90% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.13 90.90% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.8 90.62% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.9 90.68% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-pypy3.10 90.54% <100.00%> (+<0.01%) ⬆️
windows-2022-3.10 90.74% <100.00%> (+<0.01%) ⬆️
windows-2022-3.11 90.68% <100.00%> (+<0.01%) ⬆️
windows-2022-3.12 90.89% <100.00%> (+<0.01%) ⬆️
windows-2022-3.13 90.89% <100.00%> (+<0.01%) ⬆️
windows-2022-3.8 90.72% <100.00%> (+<0.01%) ⬆️
windows-2022-3.9 90.67% <100.00%> (+<0.01%) ⬆️
windows-2022-pypy3.10 90.74% <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 Sentry.
📢 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.

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.

2 participants