babel icon indicating copy to clipboard operation
babel copied to clipboard

Make pgettext search plurals when translation is not found

Open tomasr8 opened this issue 1 year ago • 1 comments

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.

tomasr8 avatar May 13 '24 15:05 tomasr8

Codecov Report

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

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     

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

codecov[bot] avatar May 13 '24 15:05 codecov[bot]