Changeset 1065
- Timestamp:
- 11/03/05 10:50:41 (3 years ago)
- Files:
-
- django/branches/i18n/django/core/template/__init__.py (modified) (3 diffs)
- django/branches/i18n/tests/othertests/templates.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/core/template/__init__.py
r1061 r1065 349 349 # First read the variable part - decide on wether we need 350 350 # to parse a string or a variable by peeking into the stream 351 if self.peek_char() in (' "', "'"):351 if self.peek_char() in ('_', '"', "'"): 352 352 self.var = self.read_constant_string_token() 353 353 else: … … 383 383 val = '' 384 384 qchar = None 385 i18n = False 385 386 self.next_char() 387 if self.current == '_': 388 i18n = True 389 self.next_char() 390 if self.current != '(': 391 raise TemplateSyntaxError, "Bad character (expecting '(') '%s'" % self.current 392 self.next_char() 386 393 if not self.current in ('"', "'"): 387 394 raise TemplateSyntaxError, "Bad character (expecting '\"' or ''') '%s'" % self.current … … 395 402 val += self.current 396 403 self.next_char() 404 if i18n: 405 if self.current != ')': 406 raise TemplateSyntaxError, "Bad character (expecting ')') '%s'" % self.current 407 self.next_char() 408 val = qchar+_(val.strip(qchar))+qchar 397 409 return val 398 410 django/branches/i18n/tests/othertests/templates.py
r1064 r1065 253 253 # usage of the get_available_languages tag 254 254 'i18n12': ('{% load i18n %}{% get_available_languages as langs %}{% for lang in langs %}{% ifequal lang.0 "de" %}{{ lang.0 }}{% endifequal %}{% endfor %}', {}, 'de'), 255 256 # translation of a constant string 257 'i18n13': ('{{ _("Page not found") }}', {'LANGUAGE_CODE': 'de'}, 'Seite nicht gefunden'), 255 258 } 256 259
