[3.12] bpo-18319: gettext() can retrieve a message even if a plural form exists (GH-19869) (#107108)

(cherry picked from commit 54632528ee)

Co-authored-by: Gilles Bassière <gbassiere@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-07-23 05:29:08 -07:00 committed by GitHub
parent af95a1da46
commit bd72fb19ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -422,10 +422,12 @@ class GNUTranslations(NullTranslations):
missing = object()
tmsg = self._catalog.get(message, missing)
if tmsg is missing:
if self._fallback:
return self._fallback.gettext(message)
return message
return tmsg
tmsg = self._catalog.get((message, self.plural(1)), missing)
if tmsg is not missing:
return tmsg
if self._fallback:
return self._fallback.gettext(message)
return message
def ngettext(self, msgid1, msgid2, n):
try: