{% blocktrans %} does not escape % in text
When you try to use a blocktrans with a percent sign in it. When the percent is escaped (%%) it renders fine. It does not occur when using a trans tag.
>>> from django.template import Context, Template
>>> t1 = Template('{% load i18n %}{% blocktrans %}We lost 5% today.{% endblocktrans %}')
>>> t2 = Template('{% load i18n %}{% blocktrans %}We lost 5%% today.{% endblocktrans %}')
>>> t3 = Template('{% load i18n %}{% trans "We lost 5% today." %}')
>>> c = Context()
>>> t1.render(c)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "D:\Python\lib\site-packages\django\template\__init__.py", line 181, in render
return self.nodelist.render(context)
File "D:\Python\lib\site-packages\django\template\__init__.py", line 736, in render
bits.append(self.render_node(node, context))
File "D:\Python\lib\site-packages\django\template\__init__.py", line 764, in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering: unsupported format character 't' (0x74) at index 11
Original Traceback (most recent call last):
File "D:\Python\lib\site-packages\django\template\__init__.py", line 754, in render_node
result = node.render(context)
File "D:\Python\lib\site-packages\django\templatetags\i18n.py", line 73, in render
result = translation.ugettext(singular) % context
ValueError: unsupported format character 't' (0x74) at index 11
>>> t2.render(c)
u'We lost 5% today.'
>>> t3.render(c)
u'We lost 5% today.'
Change History
(14)
Triage Stage: |
Unreviewed → Accepted
|
Component: |
Translations → Internationalization
|
Owner: |
changed from nobody to Tomáš Kopeček
|
Status: |
new → assigned
|
Keywords: |
sprintsept14 added
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Patch needs improvement: |
set
|
Resolution: |
fixed
|
Status: |
closed → reopened
|
Cc: |
permonik@… added; permonik@… removed
|
Resolution: |
→ fixed
|
Status: |
reopened → closed
|
Triage Stage: |
Ready for checkin → Accepted
|
Easy pickings: |
unset
|
Severity: |
→ Normal
|
Type: |
→ Uncategorized
|
UI/UX: |
unset
|
Blocktrans creates template string with %()s, but doesn't correctly escape % signs in original text. Patch attached, make-messages.py works as intended - so no other harm in i18n machinery.