From afbf913b90a820702a2a4cad669c25d8808a5843 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 15 Oct 2012 10:00:22 +0200 Subject: [PATCH] Build context strings out of [u|n]gettext The context strings in [n]pgettext functions should not be marked themselves for translation. --- django/utils/translation/trans_real.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 6911c2c723..cce2a8cb86 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -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)