diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-09-08 13:24:41 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-09-08 13:24:41 +0000 |
| commit | 16bb9c594cf7306f4b2fc3ba915be43b05dad5d2 (patch) | |
| tree | 447587001df5ccf70e094b6e89d796c80c54ae7a /django | |
| parent | 2b4341d532b376702a17212a9ff9f8710ca4c14a (diff) | |
Fixed #16516 -- Relaxed the blocktrans rendering a little by falling back to the default language if resolving one of the arguments fails, raising a KeyError. Thanks, Claude Paroz and Aymeric Augustin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/templatetags/i18n.py | 7 | ||||
| -rw-r--r-- | django/utils/translation/__init__.py | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py index 8fc312c066..519354985f 100644 --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -128,7 +128,12 @@ class BlockTranslateNode(Node): result = re.sub(u'%(?!\()', u'%%', result) data = dict([(v, _render_value_in_context(context.get(v, ''), context)) for v in vars]) context.pop() - return result % data + try: + result = result % data + except KeyError: + with translation.override(None): + result = self.render(context) + return result class LanguageNode(Node): diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index acf4d8dead..8ad9c5d59a 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -115,7 +115,10 @@ class override(object): self.old_language = get_language() def __enter__(self): - activate(self.language) + if self.language is not None: + activate(self.language) + else: + deactivate_all() def __exit__(self, exc_type, exc_value, traceback): if self.deactivate: |
