Ticket #15535: ticket15535_r15708.diff

File ticket15535_r15708.diff, 1.6 KB (added by Stephen Burrows, 14 years ago)
  • django/templatetags/i18n.py

    diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
    index 0cb7e6a..e6b3b61 100644
    a b class BlockTranslateNode(Node):  
    113113            result = translation.ugettext(singular)
    114114        # Escape all isolated '%' before substituting in the context.
    115115        result = re.sub(u'%(?!\()', u'%%', result)
    116         data = dict([(v, _render_value_in_context(context[v], context)) for v in vars])
     116        data = dict([(v, _render_value_in_context(context.get(v, ''), context)) for v in vars])
    117117        context.pop()
    118118        return result % data
    119119
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index 54c97ce..fb47b27 100644
    a b class Templates(unittest.TestCase):  
    12451245            'i18n32': ('{% load i18n %}{{ "hu"|language_name }} {{ "hu"|language_name_local }} {{ "hu"|language_bidi }}', {}, u'Hungarian Magyar False'),
    12461246            'i18n33': ('{% load i18n %}{{ langcode|language_name }} {{ langcode|language_name_local }} {{ langcode|language_bidi }}', {'langcode': 'nl'}, u'Dutch Nederlands False'),
    12471247
     1248            # blocktrans handling of variables which are not in the context.
     1249            'i18n34': ('{% load i18n %}{% blocktrans %}{{ missing }}{% endblocktrans %}', {}, u''),
     1250
    12481251            ### HANDLING OF TEMPLATE_STRING_IF_INVALID ###################################
    12491252
    12501253            'invalidstr01': ('{{ var|default:"Foo" }}', {}, ('Foo','INVALID')),
Back to Top