diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py index 7c29f63c59..984f122eac 100644 --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -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: diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 4dcf0281a4..8e73e91693 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -1507,6 +1507,8 @@ class TemplateTests(TestCase): 'invalidstr04_2': ('{% if var|default:"Foo" %}Yes{% else %}No{% endif %}', {}, 'Yes'), 'invalidstr05': ('{{ var }}', {}, ('', ('INVALID %s', 'var'))), 'invalidstr06': ('{{ var.prop }}', {'var': {}}, ('', ('INVALID %s', 'var.prop'))), + 'invalidstr07': ('{% load i18n %}{% blocktrans %}{{ var }}{% endblocktrans %}', + {}, ('', ('INVALID %s', 'var'))), ### MULTILINE #############################################################