Ticket #13568: i18n_13568.diff

File i18n_13568.diff, 1.8 KB (added by deltoide, 15 years ago)

Fix + regression test

  • django/templatetags/i18n.py

     
    7676        if self.plural and self.countervar and self.counter:
    7777            count = self.counter.resolve(context)
    7878            context[self.countervar] = count
    79             plural, vars = self.render_token_list(self.plural)
     79            plural, plural_vars = self.render_token_list(self.plural)
    8080            result = translation.ungettext(singular, plural, count)
     81            if count != 1:
     82                vars = plural_vars
    8183        else:
    8284            result = translation.ugettext(singular)
    8385        # Escape all isolated '%' before substituting in the context.
  • tests/regressiontests/templates/tests.py

     
    11041104            'i18n24': ("{% load i18n %}{% trans 'Page not found'|upper %}", {'LANGUAGE_CODE': 'de'}, u'SEITE NICHT GEFUNDEN'),
    11051105            'i18n25': ('{% load i18n %}{% trans somevar|upper %}', {'somevar': 'Page not found', 'LANGUAGE_CODE': 'de'}, u'SEITE NICHT GEFUNDEN'),
    11061106
     1107            # translation of plural form with extra field in singular form (#XXX)
     1108            'i18n26': ('{% load i18n %}{% blocktrans with myextra_field as extra_field count number as counter %}singular {{ extra_field }}{% plural %}plural{% endblocktrans %}', {'number': 1, 'myextra_field': 'test'}, "singular test"),
     1109
    11071110            ### HANDLING OF TEMPLATE_STRING_IF_INVALID ###################################
    11081111
    11091112            'invalidstr01': ('{{ var|default:"Foo" }}', {}, ('Foo','INVALID')),
Back to Top