Ticket #5885: template_simple_tag_i18n_fix.2.diff
File template_simple_tag_i18n_fix.2.diff, 1.1 KB (added by , 17 years ago) |
---|
-
django/template/__init__.py
127 127 self.params = params 128 128 129 129 def __str__(self): 130 return self.msg % self.params 131 130 try: 131 return self.msg % self.params 132 except UnicodeDecodeError: 133 return self.msg % (self.params[0],str(self.params[1])) 134 132 135 class InvalidTemplateLibrary(Exception): 133 136 pass 134 137 … … 692 695 if var[0] in "\"'" and var[0] == var[-1]: 693 696 self.literal = var[1:-1] 694 697 698 elif var[0:2] == "_(" and var[-1] == ")": 699 match = re.match("\_\(('(?:[^']+')|(?:\"[^\"]+)\")\)",var) 700 if match is not None: 701 self.literal = _(match.group(1)[1:-2]) 702 else: 703 raise AttributeError('Invalid translation string %s.'%var) 695 704 else: 696 705 # Otherwise we'll set self.lookups so that resolve() knows we're 697 706 # dealing with a bonafide variable