missing = object()
tmsg = self._catalog.get(ctxt_msg_id, missing)
if tmsg is missing:
- if self._fallback:
- return self._fallback.pgettext(context, message)
- return message
- return tmsg
+ tmsg = self._catalog.get((ctxt_msg_id, self.plural(1)), missing)
+ if tmsg is not missing:
+ return tmsg
+ if self._fallback:
+ return self._fallback.pgettext(context, message)
+ return message
def npgettext(self, context, msgid1, msgid2, n):
ctxt_msg_id = self.CONTEXT % (context, msgid1)
x = gettext.npgettext('With context',
'There is %s file', 'There are %s files', 2)
eq(x, 'Hay %s ficheros (context)')
+ x = gettext.pgettext('With context', 'There is %s file')
+ eq(x, 'Hay %s fichero (context)')
def test_plural_forms2(self):
eq = self.assertEqual
x = t.npgettext('With context',
'There is %s file', 'There are %s files', 2)
eq(x, 'Hay %s ficheros (context)')
+ x = gettext.pgettext('With context', 'There is %s file')
+ eq(x, 'Hay %s fichero (context)')
# Examples from http://www.gnu.org/software/gettext/manual/gettext.html