Commit c8d2120b authored by Thejaswi Puthraya's avatar Thejaswi Puthraya Committed by Tim Graham
Browse files

Fixed #26705 -- Fixed plural versions of languages not supported by Django.

parent c4980e28
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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:
+13 −0
Original line number Diff line number Diff line
@@ -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')