diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
index c7202e2..ebb4d02 100644
a
|
b
|
class BlockTranslateNode(Node):
|
122 | 122 | result = re.sub(u'%(?!\()', u'%%', result) |
123 | 123 | data = dict([(v, _render_value_in_context(context.get(v, ''), context)) for v in vars]) |
124 | 124 | context.pop() |
125 | | return result % data |
| 125 | try: |
| 126 | result = result % data |
| 127 | except KeyError: |
| 128 | with translation.override('en'): |
| 129 | result = self.render(context) |
| 130 | return result |
126 | 131 | |
127 | 132 | |
128 | 133 | class LanguageNode(Node): |
diff --git a/tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.mo b/tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000000000000000000000000000000000..f0a21797676abbe377b4637c57fe40fce594a5b2
GIT binary patch
literal 454
zcmYL_%}T>S5XYnFB}Wf};9)!nEjl%u3N71K#M(l^U@g)6+HBJ;$!^%)h<y;>!e{bX
zoK`Ty{+JK`Gds-B$<bFpc1WBP*TgX~Bz86@PKg&{d=La{@@K?1#q{=l<Qhx1phYP`
zIk;?9(mJEtt`p3y*~q2GS%z;^R7P{iHbUnHyma1$3t1WKF>$%d@S)BfriMc}e@=01
zrSQ~&kHSk1al|5wVq~|#dc51cqC6rYF64*WO>T4yBZe`9nDK58qb}*5g!7nMp<N-o
zu^h&Qs541*o!26lm`YJ{SXmgZ?0um+#^!fnGD{}S;;a*eW23#)G-_MXPF{Zco2n2>
z4`8_#)=58lO{dszbh|HC(&9ufO{R3tq5rOYI4^1|3Y;2SIu5$pr*0Gv;4d7tG+c~;
UwZkAW8nh{a?)86LEqB-b1z6B~F#rGn
literal 0
HcmV?d00001
diff --git a/tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.po b/tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.po
new file mode 100644
index 0000000..8e9b9e1
-
|
+
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | msgid "" |
| 7 | msgstr "" |
| 8 | "Project-Id-Version: django tests\n" |
| 9 | "Report-Msgid-Bugs-To: \n" |
| 10 | "POT-Creation-Date: 2010-02-14 17:33+0100\n" |
| 11 | "PO-Revision-Date: 2011-01-21 21:37-0300\n" |
| 12 | "Last-Translator: Claude\n" |
| 13 | "Language-Team: fr <fr@li.org>\n" |
| 14 | "MIME-Version: 1.0\n" |
| 15 | "Content-Type: text/plain; charset=UTF-8\n" |
| 16 | "Content-Transfer-Encoding: 8bit\n" |
| 17 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" |
| 18 | |
| 19 | #: template.html:3 |
| 20 | msgid "My name is %(person)s." |
| 21 | msgstr "Mon nom est %(personne)s." |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 0b955ad..e58c89c 100644
a
|
b
|
from threading import local
|
9 | 9 | from django.conf import settings |
10 | 10 | from django.template import Template, Context |
11 | 11 | from django.test import TestCase, RequestFactory |
| 12 | from django.test.utils import override_settings |
12 | 13 | from django.utils.formats import (get_format, date_format, time_format, |
13 | 14 | localize, localize_input, iter_format_modules, get_format_modules) |
14 | 15 | from django.utils.importlib import import_module |
… |
… |
class TranslationTests(TestCase):
|
129 | 130 | self.assertEqual(to_language('en_US'), 'en-us') |
130 | 131 | self.assertEqual(to_language('sr_Lat'), 'sr-lat') |
131 | 132 | |
| 133 | @override_settings( |
| 134 | LOCALE_PATHS = ( |
| 135 | os.path.join(os.path.dirname(os.path.abspath(__file__)), 'other', 'locale'), |
| 136 | ), |
| 137 | ) |
| 138 | def test_bad_placeholder(self): |
| 139 | """ |
| 140 | Error in translation file should not crash template rendering |
| 141 | (%(person)s is translated as %(personne)s in fr.po) |
| 142 | """ |
| 143 | from django.template import Template, Context |
| 144 | with translation.override('fr'): |
| 145 | t = Template('{% load i18n %}{% blocktrans %}My name is {{ person }}.{% endblocktrans %}') |
| 146 | c = Context({'person': u"James"}) |
| 147 | rendered = t.render(c) |
| 148 | self.assertEqual(rendered, u"My name is James.") |
| 149 | |
132 | 150 | |
133 | 151 | class FormattingTests(TestCase): |
134 | 152 | |