Ticket #12104: django_svn_blocktrans_patch.diff
File django_svn_blocktrans_patch.diff, 1.0 KB (added by , 15 years ago) |
---|
-
i18n.py
3 3 from django.template import Node, Variable, 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 from django.template import Context, Template 6 7 from django.utils import translation 7 8 from django.utils.encoding import force_unicode 8 9 … … 82 83 result = translation.ugettext(singular) 83 84 # Escape all isolated '%' before substituting in the context. 84 85 result = re.sub(u'%(?!\()', u'%%', result) 85 data = dict([(v, _render_value_in_context(context[v], context)) for v in vars]) 86 data = {} 87 c = Context(context) 88 for v in vars: 89 t = Template("{{%s}}" % v) 90 rendered_val = _render_value_in_context(t.render(c), context) 91 data[v] = rendered_val 86 92 context.pop() 87 93 return result % data 88 94