diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-20 12:29:56 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-20 12:29:56 +0000 |
| commit | cc6139ab50d07b4c61cf8302ebb16d764a995d9a (patch) | |
| tree | 71511fa86738c8051db9798515966aef20ee46f9 | |
| parent | 3742e35df34f4a3b31423f0e2676bb873cf45a8e (diff) | |
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
| -rw-r--r-- | django/templatetags/i18n.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py index d5b0741a61..cec35fb48e 100644 --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -1,3 +1,5 @@ +import re + from django.template import Node, Variable from django.template import TemplateSyntaxError, TokenParser, Library from django.template import TOKEN_TEXT, TOKEN_VAR @@ -68,9 +70,11 @@ class BlockTranslateNode(Node): count = self.counter.resolve(context) context[self.countervar] = count plural = self.render_token_list(self.plural) - result = translation.ungettext(singular, plural, count) % context + result = translation.ungettext(singular, plural, count) else: - result = translation.ugettext(singular) % context + result = translation.ugettext(singular) + # Escape all isolated '%' before substituting in the context. + result = re.sub('%(?!\()', '%%', result) % context context.pop() return result |
