1
0
mirror of https://github.com/django/django.git synced 2025-01-30 12:09:25 +00:00

Build context strings out of [u|n]gettext

The context strings in [n]pgettext functions should not be marked
themselves for translation.
This commit is contained in:
Claude Paroz 2012-10-15 10:00:22 +02:00
parent a451d2b4a2
commit afbf913b90

View File

@ -273,7 +273,8 @@ else:
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 @@ else:
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)