diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-02-08 11:06:54 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-02-08 11:06:54 +0100 |
| commit | 02add43568b694ef25afeae474b5b1da883826c6 (patch) | |
| tree | 9234f67a58a58a9560c3543bd1d37f19cf1801da /django | |
| parent | 8847a0c601e4261823b1726b2db73eec2ac17940 (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/templatetags/i18n.py | 10 |
1 files changed, 8 insertions, 2 deletions
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: |
