summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThejaswi Puthraya <thejaswi.puthraya@gmail.com>2016-06-07 18:32:42 +0530
committerTim Graham <timograham@gmail.com>2016-06-08 16:17:17 -0400
commitc8d2120b06e1b82cb0db896aa0f9767b2f14256c (patch)
treebd758c5b2b3c7edede5431e50f3fe6351aec3df3
parentc4980e28e57f385d8ffed5e32ce373e52ce61049 (diff)
Fixed #26705 -- Fixed plural versions of languages not supported by Django.
-rw-r--r--django/utils/translation/trans_real.py3
-rw-r--r--tests/i18n/tests.py13
2 files changed, 16 insertions, 0 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 7a2a1c63a2..d7e97e7ed2 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -113,6 +113,9 @@ class DjangoTranslation(gettext_module.GNUTranslations):
self.__to_language = to_language(language)
self.__locale = to_locale(language)
self._catalog = None
+ # If a language doesn't have a catalog, use the Germanic default for
+ # pluralization: anything except one is pluralized.
+ self.plural = lambda n: int(n != 1)
if self.domain == 'django':
if localedirs is not None:
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 5084f2dc1d..7292bd5a0a 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1925,3 +1925,16 @@ class NonDjangoLanguageTests(SimpleTestCase):
def test_non_django_language(self):
self.assertEqual(get_language(), 'xxx')
self.assertEqual(ugettext("year"), "reay")
+
+ @override_settings(
+ USE_I18N=True,
+ LANGUAGES=[
+ ('en-us', 'English'),
+ # xyz language has no locale files
+ ('xyz', 'XYZ'),
+ ],
+ )
+ @translation.override('xyz')
+ def test_plural_non_django_language(self):
+ self.assertEqual(get_language(), 'xyz')
+ self.assertEqual(ungettext('year', 'years', 2), 'years')