summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-09-08 13:25:41 +0000
committerJannis Leidel <jannis@leidel.info>2011-09-08 13:25:41 +0000
commit387e192f2584d283d989ebe92e63d174413e30e4 (patch)
tree4734b542a0729c4661eb61326c0bf238f6e2c2f4 /tests
parent7cb140e6d86e9c592983ddb50bfd82480ecec7eb (diff)
Fixed #16721 -- Made sure that blocktrans correctly handles percents (%), even in the plural block. Thanks for the initial patch, Claude Paroz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16730 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mobin668 -> 922 bytes
-rw-r--r--tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po12
-rw-r--r--tests/regressiontests/i18n/tests.py13
3 files changed, 25 insertions, 0 deletions
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 241de05ddb..a1a93c8329 100644
--- a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo
+++ b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo
Binary files 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 2d9b89e23c..7226ad1943 100644
--- a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po
+++ b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po
@@ -40,3 +40,15 @@ msgid "%d result"
msgid_plural "%d results"
msgstr[0] "%d Resultat"
msgstr[1] "%d Resultate"
+
+#: models.py:13
+#, python-format
+msgid "The result was %(percent)s%%"
+msgstr "Das Ergebnis war %(percent)s%%"
+
+#: models.py:13
+#, python-format
+msgid "%(percent)s%% represents %(num)s object"
+msgid_plural "%(percent)s%% represents %(num)s objects"
+msgstr[0] "%(percent)s%% stellt %(num)s Objekt dar"
+msgstr[1] "%(percent)s%% stellt %(num)s Objekte dar"
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index f230e59556..e6799ae28e 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -618,6 +618,19 @@ class MiscTests(TestCase):
r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
self.assertEqual(g(r), 'zh-cn')
+ def test_percent_in_translatable_block(self):
+ extended_locale_paths = settings.LOCALE_PATHS + (
+ os.path.join(here, 'other', 'locale'),
+ )
+ with self.settings(LOCALE_PATHS=extended_locale_paths):
+ t_sing = Template("{% load i18n %}{% blocktrans %}The result was {{ percent }}%{% endblocktrans %}")
+ t_plur = Template("{% load i18n %}{% blocktrans count num as number %}{{ percent }}% represents {{ num }} object{% plural %}{{ percent }}% represents {{ num }} objects{% endblocktrans %}")
+ with translation.override('de'):
+ self.assertEqual(t_sing.render(Context({'percent': 42})), u'Das Ergebnis war 42%')
+ self.assertEqual(t_plur.render(Context({'percent': 42, 'num': 1})), u'42% stellt 1 Objekt dar')
+ self.assertEqual(t_plur.render(Context({'percent': 42, 'num': 4})), u'42% stellt 4 Objekte dar')
+
+
class ResolutionOrderI18NTests(TestCase):
def setUp(self):