Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit41756e3

Browse files
miss-islingtontomasr8ambv
authored
[3.11]gh-62519: Make pgettext search plurals when translation is not found (GH-107118) (GH-107133)
(cherry picked from commitb3c34e5)Co-authored-by: Tomas R <tomas.roun8@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent012bc13 commit41756e3

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

‎Lib/gettext.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,12 @@ def pgettext(self, context, message):
444444
missing=object()
445445
tmsg=self._catalog.get(ctxt_msg_id,missing)
446446
iftmsgismissing:
447-
ifself._fallback:
448-
returnself._fallback.pgettext(context,message)
449-
returnmessage
450-
returntmsg
447+
tmsg=self._catalog.get((ctxt_msg_id,self.plural(1)),missing)
448+
iftmsgisnotmissing:
449+
returntmsg
450+
ifself._fallback:
451+
returnself._fallback.pgettext(context,message)
452+
returnmessage
451453

452454
defnpgettext(self,context,msgid1,msgid2,n):
453455
ctxt_msg_id=self.CONTEXT% (context,msgid1)

‎Lib/test/test_gettext.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ def test_plural_context_forms1(self):
329329
x=gettext.npgettext('With context',
330330
'There is %s file','There are %s files',2)
331331
eq(x,'Hay %s ficheros (context)')
332+
x=gettext.pgettext('With context','There is %s file')
333+
eq(x,'Hay %s fichero (context)')
332334

333335
deftest_plural_forms2(self):
334336
eq=self.assertEqual
@@ -349,6 +351,8 @@ def test_plural_context_forms2(self):
349351
x=t.npgettext('With context',
350352
'There is %s file','There are %s files',2)
351353
eq(x,'Hay %s ficheros (context)')
354+
x=gettext.pgettext('With context','There is %s file')
355+
eq(x,'Hay %s fichero (context)')
352356

353357
# Examples from http://www.gnu.org/software/gettext/manual/gettext.html
354358

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make:func:`gettext.pgettext` search plural definitions when
2+
translation is not found.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp