Author: mtredinnick
Date: 2007-10-20 07:29:56 -0500 (Sat, 20 Oct 2007)
New Revision: 6565
Modified:
django/trunk/django/templatetags/i18n.py
Log:
Fixed #4982 -- Fixed handling of '%' symbols in 'blocktrans' blocks. Thanks,
[EMAIL PROTECTED]
Modified: django/trunk/django/templatetags/i18n.py
===================================================================
--- django/trunk/django/templatetags/i18n.py 2007-10-20 12:21:16 UTC (rev
6564)
+++ django/trunk/django/templatetags/i18n.py 2007-10-20 12:29:56 UTC (rev
6565)
@@ -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 @@
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---