Ticket #12104: blocktrans_variable_attribute_works.diff
File blocktrans_variable_attribute_works.diff, 1.1 KB (added by , 15 years ago) |
---|
-
django/templatetags/i18n.py
1 1 import re 2 2 3 from django.template import Node, Variable, Variable Node, _render_value_in_context3 from django.template import Node, Variable, VariableDoesNotExist, VariableNode, _render_value_in_context 4 4 from django.template import TemplateSyntaxError, TokenParser, Library 5 5 from django.template import TOKEN_TEXT, TOKEN_VAR 6 6 from django.utils import translation … … 82 82 result = translation.ugettext(singular) 83 83 # Escape all isolated '%' before substituting in the context. 84 84 result = re.sub(u'%(?!\()', u'%%', result) 85 data = dict([(v, _render_value_in_context(context[v], context)) for v in vars]) 85 data = [] 86 for v in vars: 87 try: 88 data.append((v, Variable(v).resolve(context))) 89 except VariableDoesNotExist: 90 data.append((v, '')) 91 data = dict(data) 86 92 context.pop() 87 93 return result % data 88 94