python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.29k stars 432 forks source link

Make pgettext search plurals when translation is not found #1085

Open tomasr8 opened 1 month ago

tomasr8 commented 1 month ago

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: https://github.com/python/cpython/issues/62519 https://github.com/python/cpython/pull/107118

This PR applies the same patch to babel.

codecov[bot] commented 1 month ago

Codecov Report

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

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.