Skip to content
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

Make pgettext search plurals when translation is not found #1085

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomasr8
Copy link
Contributor

@tomasr8 tomasr8 commented May 13, 2024

Given this po file:

msgctxt "ctx"
msgid "foo"
msgid_plural "foos"
msgstr[0] "foo translated"

pgettext fails to find the singular translation i.e. pgettext("ctx", "foo") == "foo" when one would expect to get foo translated.

The same issue has already been fixed upstream in gettext:
python/cpython#62519
python/cpython#107118

This PR applies the same patch to babel.

pgettext can now find the following translation
when using `pgettext("ctx", "foo")`:

msgctxt "ctx"
msgid "foo"
msgid_plural "foos"
msgstr[0] "foo translated"
Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.06%. Comparing base (e0d1018) to head (da2a8e4).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1085      +/-   ##
==========================================
+ Coverage   90.99%   91.06%   +0.06%     
==========================================
  Files          26       26              
  Lines        4444     4453       +9     
==========================================
+ Hits         4044     4055      +11     
+ Misses        400      398       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

None yet

1 participant