1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #21417 -- Expanded TEMPLATE_STRING_IF_INVALID in blocktrans

Thanks keturn for the reporti, Chris Medrela for details and
Tim Graham for the review.
Refs #19915.
This commit is contained in:
Claude Paroz
2014-02-08 11:06:54 +01:00
parent 8847a0c601
commit 02add43568
2 changed files with 10 additions and 2 deletions

View File

@@ -150,8 +150,14 @@ class BlockTranslateNode(Node):
else:
result = translation.ugettext(singular)
default_value = settings.TEMPLATE_STRING_IF_INVALID
render_value = lambda v: render_value_in_context(
context.get(v, default_value), context)
def render_value(key):
if key in context:
val = context[key]
else:
val = default_value % key if '%s' in default_value else default_value
return render_value_in_context(val, context)
data = dict((v, render_value(v)) for v in vars)
context.pop()
try: