Loading django/utils/translation/trans_real.py +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ class DjangoTranslation(gettext_module.GNUTranslations): def __init__(self, language): """Create a GNUTranslations() using many locale directories""" gettext_module.GNUTranslations.__init__(self) self.set_output_charset('utf-8') # For Python 2 gettext() (#25720) self.__language = language self.__to_language = to_language(language) Loading docs/releases/1.8.7.txt +3 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,6 @@ Bugfixes * Fixed a data loss possibility with :class:`~django.db.models.Prefetch` if ``to_attr`` is set to a ``ManyToManyField`` (:ticket:`25693`). * Fixed a regression in 1.8 by making ``gettext()`` once again return UTF-8 bytestrings on Python 2 if the input is a bytestring (:ticket:`25720`). tests/i18n/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,18 @@ class TranslationTests(SimpleTestCase): s4 = ugettext_lazy('Some other string') self.assertNotEqual(s, s4) @skipUnless(six.PY2, "No more bytestring translations on PY3") def test_bytestrings(self): """gettext() returns a bytestring if input is bytestring.""" # Using repr() to check translated text and type self.assertEqual(repr(gettext(b"Time")), repr(b"Time")) self.assertEqual(repr(gettext("Time")), repr("Time")) with translation.override('de', deactivate=True): self.assertEqual(repr(gettext(b"Time")), repr(b"Zeit")) self.assertEqual(repr(gettext("Time")), repr(b"Zeit")) @skipUnless(six.PY2, "No more bytestring translations on PY3") def test_lazy_and_bytestrings(self): # On Python 2, (n)gettext_lazy should not transform a bytestring to unicode Loading Loading
django/utils/translation/trans_real.py +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ class DjangoTranslation(gettext_module.GNUTranslations): def __init__(self, language): """Create a GNUTranslations() using many locale directories""" gettext_module.GNUTranslations.__init__(self) self.set_output_charset('utf-8') # For Python 2 gettext() (#25720) self.__language = language self.__to_language = to_language(language) Loading
docs/releases/1.8.7.txt +3 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,6 @@ Bugfixes * Fixed a data loss possibility with :class:`~django.db.models.Prefetch` if ``to_attr`` is set to a ``ManyToManyField`` (:ticket:`25693`). * Fixed a regression in 1.8 by making ``gettext()`` once again return UTF-8 bytestrings on Python 2 if the input is a bytestring (:ticket:`25720`).
tests/i18n/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,18 @@ class TranslationTests(SimpleTestCase): s4 = ugettext_lazy('Some other string') self.assertNotEqual(s, s4) @skipUnless(six.PY2, "No more bytestring translations on PY3") def test_bytestrings(self): """gettext() returns a bytestring if input is bytestring.""" # Using repr() to check translated text and type self.assertEqual(repr(gettext(b"Time")), repr(b"Time")) self.assertEqual(repr(gettext("Time")), repr("Time")) with translation.override('de', deactivate=True): self.assertEqual(repr(gettext(b"Time")), repr(b"Zeit")) self.assertEqual(repr(gettext("Time")), repr(b"Zeit")) @skipUnless(six.PY2, "No more bytestring translations on PY3") def test_lazy_and_bytestrings(self): # On Python 2, (n)gettext_lazy should not transform a bytestring to unicode Loading