diff options
| author | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 16:50:41 +0000 |
|---|---|---|
| committer | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 16:50:41 +0000 |
| commit | 11e6a880111f60b9d037a4f1f53b7b68d1da552f (patch) | |
| tree | 6de274d9b3d7fc617b0eb4fdfe3b5af042c54d23 /django | |
| parent | 1470bb0b2391028e00ea1eb95eca7c90e12b004c (diff) | |
i18n: readded constant string translations, needed for template tags with string constants
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@1065 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/template/__init__.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/django/core/template/__init__.py b/django/core/template/__init__.py index 0011cb2c9a..2f1caf657f 100644 --- a/django/core/template/__init__.py +++ b/django/core/template/__init__.py @@ -348,7 +348,7 @@ class FilterParser: self.current_filter_arg = None # First read the variable part - decide on wether we need # to parse a string or a variable by peeking into the stream - if self.peek_char() in ('"', "'"): + if self.peek_char() in ('_', '"', "'"): self.var = self.read_constant_string_token() else: self.var = self.read_alphanumeric_token() @@ -382,7 +382,14 @@ class FilterParser: or ' characters. The string is returned with it's delimiters.""" val = '' qchar = None + i18n = False self.next_char() + if self.current == '_': + i18n = True + self.next_char() + if self.current != '(': + raise TemplateSyntaxError, "Bad character (expecting '(') '%s'" % self.current + self.next_char() if not self.current in ('"', "'"): raise TemplateSyntaxError, "Bad character (expecting '\"' or ''') '%s'" % self.current qchar = self.current @@ -394,6 +401,11 @@ class FilterParser: val += self.current val += self.current self.next_char() + if i18n: + if self.current != ')': + raise TemplateSyntaxError, "Bad character (expecting ')') '%s'" % self.current + self.next_char() + val = qchar+_(val.strip(qchar))+qchar return val def read_alphanumeric_token(self): |
