diff options
| author | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 17:10:16 +0000 |
|---|---|---|
| committer | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 17:10:16 +0000 |
| commit | 9e724c25236b1e00a36a146e66b5deaa43d2af96 (patch) | |
| tree | 5ea3f671bb5c24f6d959293441069b57f01031a5 /django/utils | |
| parent | 11e6a880111f60b9d037a4f1f53b7b68d1da552f (diff) | |
i18n: fixed documentation and message scanner for constant string translations
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@1066 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/translation.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/django/utils/translation.py b/django/utils/translation.py index a8b9192bc6..0d40a636c8 100644 --- a/django/utils/translation.py +++ b/django/utils/translation.py @@ -364,6 +364,7 @@ inline_re = re.compile(r"""^\s*trans\s+((?:".*?")|(?:'.*?'))\s*""") block_re = re.compile(r"""^\s*blocktrans(?:\s+|$)""") endblock_re = re.compile(r"""^\s*endblocktrans$""") plural_re = re.compile(r"""^\s*plural$""") +constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""") def templateize(src): from django.core.template import tokenize, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK """ @@ -414,6 +415,7 @@ def templateize(src): if t.token_type == TOKEN_BLOCK: imatch = inline_re.match(t.contents) bmatch = block_re.match(t.contents) + cmatches = constant_re.findall(t.contents) if imatch: g = imatch.group(1) if g[0] == '"': g = g.strip('"') @@ -424,11 +426,17 @@ def templateize(src): inplural = False singular = [] plural = [] + elif cmatches: + for cmatch in cmatches: + out.write(' _(%s) ' % cmatch) else: out.write(blankout(t.contents, 'B')) elif t.token_type == TOKEN_VAR: parts = t.contents.split('|') - for p in parts: + cmatch = constant_re.match(parts[0]) + if cmatch: + out.write(' _(%s) ' % cmatch.group(1)) + for p in parts[1:]: if p.find(':_(') >= 0: out.write(' %s ' % p.split(':',1)[1]) else: |
