Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build context strings out of [u|n]gettext

The context strings in [n]pgettext functions should not be marked
themselves for translation.
  • Loading branch information...
commit afbf913b90a820702a2a4cad669c25d8808a5843 1 parent a451d2b
@claudep claudep authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 django/utils/translation/trans_real.py
View
10 django/utils/translation/trans_real.py
@@ -273,7 +273,8 @@ def ugettext(message):
return do_translate(message, 'ugettext')
def pgettext(context, message):
- result = ugettext("%s%s%s" % (context, CONTEXT_SEPARATOR, message))
+ msg_with_ctxt = "%s%s%s" % (context, CONTEXT_SEPARATOR, message)
+ result = ugettext(msg_with_ctxt)
if CONTEXT_SEPARATOR in result:
# Translation not found
result = message
@@ -319,9 +320,10 @@ def ungettext(singular, plural, number):
return do_ntranslate(singular, plural, number, 'ungettext')
def npgettext(context, singular, plural, number):
- result = ungettext("%s%s%s" % (context, CONTEXT_SEPARATOR, singular),
- "%s%s%s" % (context, CONTEXT_SEPARATOR, plural),
- number)
+ msgs_with_ctxt = ("%s%s%s" % (context, CONTEXT_SEPARATOR, singular),
+ "%s%s%s" % (context, CONTEXT_SEPARATOR, plural),
+ number)
+ result = ungettext(*msgs_with_ctxt)
if CONTEXT_SEPARATOR in result:
# Translation not found
result = ungettext(singular, plural, number)
Please sign in to comment.
Something went wrong with that request. Please try again.