Skip to content

Make pgettext search plurals when translation is not found #1085

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

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

tomasr8
Copy link
Member

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

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 (e5ff4e3).
Report is 11 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.

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akx akx enabled auto-merge (squash) July 10, 2024 11:35
@akx akx disabled auto-merge July 10, 2024 11:37
tomasr8 added 2 commits July 11, 2024 09:00
pgettext can now find the following translation
when using `pgettext("ctx", "foo")`:

msgctxt "ctx"
msgid "foo"
msgid_plural "foos"
msgstr[0] "foo translated"
@akx akx merged commit 8de07f3 into python-babel:master Jul 11, 2024
23 checks passed
@tomasr8 tomasr8 deleted the pgettext branch July 11, 2024 06:21
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.

2 participants