babel icon indicating copy to clipboard operation
babel copied to clipboard

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

Open tomasr8 opened this issue 1 year ago • 1 comments

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)

tomasr8 avatar Mar 09 '25 14:03 tomasr8

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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%) :arrow_up:
macos-14-3.11 90.67% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.12 90.88% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.13 90.88% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.8 90.60% <100.00%> (+<0.01%) :arrow_up:
macos-14-3.9 90.66% <100.00%> (+<0.01%) :arrow_up:
macos-14-pypy3.10 90.73% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.10 90.75% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.11 90.69% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.12 90.90% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.13 90.90% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.8 90.62% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-3.9 90.68% <100.00%> (+<0.01%) :arrow_up:
ubuntu-24.04-pypy3.10 90.54% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.10 90.74% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.11 90.68% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.12 90.89% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.13 90.89% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.8 90.72% <100.00%> (+<0.01%) :arrow_up:
windows-2022-3.9 90.67% <100.00%> (+<0.01%) :arrow_up:
windows-2022-pypy3.10 90.74% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: 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.

codecov[bot] avatar Mar 09 '25 14:03 codecov[bot]