Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #4982 -- Fixed handling of '%' symbols in 'blocktrans' blocks. …

…Thanks,

permonik@mesias.brnonet.cz.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cc6139ab50d07b4c61cf8302ebb16d764a995d9a 1 parent 3742e35
Malcolm Tredinnick authored October 20, 2007

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

  1. 8  django/templatetags/i18n.py
8  django/templatetags/i18n.py
... ...
@@ -1,3 +1,5 @@
  1
+import re
  2
+
1 3
 from django.template import Node, Variable
2 4
 from django.template import TemplateSyntaxError, TokenParser, Library
3 5
 from django.template import TOKEN_TEXT, TOKEN_VAR
@@ -68,9 +70,11 @@ def render(self, context):
68 70
             count = self.counter.resolve(context)
69 71
             context[self.countervar] = count
70 72
             plural = self.render_token_list(self.plural)
71  
-            result = translation.ungettext(singular, plural, count) % context
  73
+            result = translation.ungettext(singular, plural, count)
72 74
         else:
73  
-            result = translation.ugettext(singular) % context
  75
+            result = translation.ugettext(singular)
  76
+        # Escape all isolated '%' before substituting in the context.
  77
+        result = re.sub('%(?!\()', '%%', result) % context
74 78
         context.pop()
75 79
         return result
76 80
 

0 notes on commit cc6139a

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