Django

Code

Changeset 6565

Show
Ignore:
Timestamp:
10/20/07 07:29:56 (1 year ago)
Author:
mtredinnick
Message:

Fixed #4982 -- Fixed handling of '%' symbols in 'blocktrans' blocks. Thanks,
permonik@mesias.brnonet.cz.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/templatetags/i18n.py

    r6399 r6565  
     1import re 
     2 
    13from django.template import Node, Variable 
    24from django.template import TemplateSyntaxError, TokenParser, Library 
     
    6971            context[self.countervar] = count 
    7072            plural = self.render_token_list(self.plural) 
    71             result = translation.ungettext(singular, plural, count) % context 
     73            result = translation.ungettext(singular, plural, count) 
    7274        else: 
    73             result = translation.ugettext(singular) % context 
     75            result = translation.ugettext(singular) 
     76        # Escape all isolated '%' before substituting in the context. 
     77        result = re.sub('%(?!\()', '%%', result) % context 
    7478        context.pop() 
    7579        return result