Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Claude Paroz authored October 15, 2012

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  django/utils/translation/trans_real.py
10  django/utils/translation/trans_real.py
@@ -273,7 +273,8 @@ def ugettext(message):
273 273
         return do_translate(message, 'ugettext')
274 274
 
275 275
 def pgettext(context, message):
276  
-    result = ugettext("%s%s%s" % (context, CONTEXT_SEPARATOR, message))
  276
+    msg_with_ctxt = "%s%s%s" % (context, CONTEXT_SEPARATOR, message)
  277
+    result = ugettext(msg_with_ctxt)
277 278
     if CONTEXT_SEPARATOR in result:
278 279
         # Translation not found
279 280
         result = message
@@ -319,9 +320,10 @@ def ungettext(singular, plural, number):
319 320
         return do_ntranslate(singular, plural, number, 'ungettext')
320 321
 
321 322
 def npgettext(context, singular, plural, number):
322  
-    result = ungettext("%s%s%s" % (context, CONTEXT_SEPARATOR, singular),
323  
-                       "%s%s%s" % (context, CONTEXT_SEPARATOR, plural),
324  
-                        number)
  323
+    msgs_with_ctxt = ("%s%s%s" % (context, CONTEXT_SEPARATOR, singular),
  324
+                      "%s%s%s" % (context, CONTEXT_SEPARATOR, plural),
  325
+                      number)
  326
+    result = ungettext(*msgs_with_ctxt)
325 327
     if CONTEXT_SEPARATOR in result:
326 328
         # Translation not found
327 329
         result = ungettext(singular, plural, number)

0 notes on commit afbf913

Please sign in to comment.
Something went wrong with that request. Please try again.