Ticket #4982: patch.diff

File patch.diff, 1016 bytes (added by permonik@…, 17 years ago)
  • templatetags/i18n.py

     
     1import re
    12from django.template import Node, resolve_variable
    23from django.template import TemplateSyntaxError, TokenParser, Library
    34from django.template import TOKEN_TEXT, TOKEN_VAR
     
    6869            count = self.counter.resolve(context)
    6970            context[self.countervar] = count
    7071            plural = self.render_token_list(self.plural)
    71             result = translation.ungettext(singular, plural, count) % context
     72            result = translation.ungettext(singular, plural, count)
    7273        else:
    73             result = translation.ugettext(singular) % context
     74            result = translation.ugettext(singular)
     75        # mask all % not directly followed by ( and rest fill with context
     76        result = re.sub('\%(?!\()', '%%', result) % context
    7477        context.pop()
    7578        return result
    7679
Back to Top