diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
index c7202e2..866db44 100644
a
|
b
|
class BlockTranslateNode(Node):
|
110 | 110 | # the end of function |
111 | 111 | context.update(tmp_context) |
112 | 112 | singular, vars = self.render_token_list(self.singular) |
| 113 | # Escape all isolated '%' |
| 114 | singular = re.sub(u'%(?!\()', u'%%', singular) |
113 | 115 | if self.plural and self.countervar and self.counter: |
114 | 116 | count = self.counter.resolve(context) |
115 | 117 | context[self.countervar] = count |
116 | 118 | plural, plural_vars = self.render_token_list(self.plural) |
| 119 | plural = re.sub(u'%(?!\()', u'%%', plural) |
117 | 120 | result = translation.ungettext(singular, plural, count) |
118 | 121 | vars.extend(plural_vars) |
119 | 122 | else: |
120 | 123 | result = translation.ugettext(singular) |
121 | | # Escape all isolated '%' before substituting in the context. |
122 | | result = re.sub(u'%(?!\()', u'%%', result) |
123 | 124 | data = dict([(v, _render_value_in_context(context.get(v, ''), context)) for v in vars]) |
124 | 125 | context.pop() |
125 | 126 | return result % data |
diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo
index 241de05..72af5d9 100644
Binary files a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo and b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo differ
diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po
index 2d9b89e..1204d80 100644
a
|
b
|
msgid "%d result"
|
40 | 40 | msgid_plural "%d results" |
41 | 41 | msgstr[0] "%d Resultat" |
42 | 42 | msgstr[1] "%d Resultate" |
| 43 | |
| 44 | #: models.py:13 |
| 45 | #, python-format |
| 46 | msgid "The result was %(percent)s%%" |
| 47 | msgstr "Das Ergebnis war %(percent)s%%" |
| 48 | |
| 49 | #: models.py:13 |
| 50 | #, python-format |
| 51 | msgid "%(percent)s%% represents %(num)s object" |
| 52 | msgid_plural "%(percent)s%% represents %(num)s objects" |
| 53 | msgstr[0] "%(percent)s%% darstellt %(num)s Objekt" |
| 54 | msgstr[1] "%(percent)s%% darstellt %(num)s Objekte" |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 0b955ad..20302d1 100644
a
|
b
|
class MiscTests(TestCase):
|
600 | 600 | r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'} |
601 | 601 | self.assertEqual(g(r), 'zh-cn') |
602 | 602 | |
| 603 | def test_percent_in_translatable_block(self): |
| 604 | extended_locale_paths = settings.LOCALE_PATHS + ( |
| 605 | os.path.join(os.path.dirname(os.path.abspath(__file__)), 'other', 'locale'), |
| 606 | ) |
| 607 | with self.settings(LOCALE_PATHS=extended_locale_paths): |
| 608 | t_sing = Template("{% load i18n %}{% blocktrans %}The result was {{ percent }}%{% endblocktrans %}") |
| 609 | t_plur = Template("{% load i18n %}{% blocktrans count num as number %}{{ percent }}% represents {{ num }} object{% plural %}{{ percent }}% represents {{ num }} objects{% endblocktrans %}") |
| 610 | with translation.override('de'): |
| 611 | self.assertEqual(t_sing.render(Context({'percent': 42})), u'Das Ergebnis war 42%') |
| 612 | self.assertEqual(t_plur.render(Context({'percent': 42, 'num': 1})), u'42% darstellt 1 Objekt') |
| 613 | self.assertEqual(t_plur.render(Context({'percent': 42, 'num': 4})), u'42% darstellt 4 Objekte') |
| 614 | |
| 615 | |
603 | 616 | class ResolutionOrderI18NTests(TestCase): |
604 | 617 | |
605 | 618 | def setUp(self): |