Changeset 757
- Timestamp:
- 10/01/05 08:05:57 (3 years ago)
- Files:
-
- django/branches/i18n/django/core/defaulttags.py (modified) (2 diffs)
- django/branches/i18n/tests/othertests/templates.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/core/defaulttags.py
r755 r757 291 291 def __init__(self, cmd): 292 292 self.cmd = cmd 293 self.i18n_re = re.compile(r'^\s* _\((.*)\)\s*$')293 self.i18n_re = re.compile(r'^\s*(_|gettext|gettext_noop)\((.*)\)\s*$') 294 294 self.ngettext_re = re.compile(r'''^\s*ngettext\(((?:".+")|(?:'.+')|(?:""".+"""))\s*,\s*((?:".+")|(?:'.+')|(?:""".+"""))\s*,\s*(.*)\)\s*$''') 295 295 … … 308 308 m = self.i18n_re.match(self.cmd) 309 309 if m: 310 s = self._resolve_var(m.group(1), context) 311 return translation.gettext(s) % context 310 f = m.group(1) 311 s = self._resolve_var(m.group(2), context) 312 if f in ('_', 'gettext'): 313 return translation.gettext(s) % context 314 elif f == 'gettext_noop': 315 return translation.gettext_noop(s) % context 316 else: 317 raise template.TemplateSyntaxError("i18n only supports _, gettext, gettext_noop and ngettext as functions, not %s" % f) 312 318 m = self.ngettext_re.match(self.cmd) 313 319 if m: django/branches/i18n/tests/othertests/templates.py
r755 r757 239 239 # translation of plural form 240 240 'i18n09': ('{% i18n ngettext("singular", "plural", count) %}', {'count': 2}, "plural"), 241 242 # simple non-translation (only marking) of a string to german 243 'i18n10': ('{% i18n gettext_noop("Page not found") %}', {'LANGUAGE_CODE': 'de'}, "Page not found"), 241 244 } 242 245
