summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2020-05-28 10:26:41 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-01 08:38:54 +0200
commitdd1ca50b096bf0351819aabc862e91a9797ddaca (patch)
tree51c8714214831e65770dde9ec85ac9f298485efd
parentdf188824738ff5e54baf2d61f6a7dff51a20f068 (diff)
Fixed #31570 -- Corrected translation loading for apps providing territorial language variants with different plural equations.
Regression in e3e48b00127c09eafe6439d980a82fc5c591b673. Thanks to Shai Berger for report, reproduce and suggested fix.
-rw-r--r--django/utils/translation/trans_real.py2
-rw-r--r--docs/releases/2.2.13.txt7
-rw-r--r--docs/releases/3.0.7.txt5
-rw-r--r--tests/i18n/loading/en/LC_MESSAGES/django.mobin0 -> 446 bytes
-rw-r--r--tests/i18n/loading/en/LC_MESSAGES/django.po23
-rw-r--r--tests/i18n/loading/en_AU/LC_MESSAGES/django.mobin0 -> 432 bytes
-rw-r--r--tests/i18n/loading/en_AU/LC_MESSAGES/django.po23
-rw-r--r--tests/i18n/loading/en_CA/LC_MESSAGES/django.mobin0 -> 389 bytes
-rw-r--r--tests/i18n/loading/en_CA/LC_MESSAGES/django.po22
-rw-r--r--tests/i18n/loading/en_NZ/LC_MESSAGES/django.mobin0 -> 387 bytes
-rw-r--r--tests/i18n/loading/en_NZ/LC_MESSAGES/django.po22
-rw-r--r--tests/i18n/loading_app/__init__.py0
-rw-r--r--tests/i18n/loading_app/apps.py5
-rw-r--r--tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mobin0 -> 380 bytes
-rw-r--r--tests/i18n/loading_app/locale/en/LC_MESSAGES/django.po25
-rw-r--r--tests/i18n/tests.py45
16 files changed, 176 insertions, 3 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index eed4705f6e..8042f6fdc4 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -96,7 +96,7 @@ class TranslationCatalog:
cat.update(trans._catalog)
break
else:
- self._catalogs.insert(0, trans._catalog)
+ self._catalogs.insert(0, trans._catalog.copy())
self._plurals.insert(0, trans.plural)
def get(self, key, default=None):
diff --git a/docs/releases/2.2.13.txt b/docs/releases/2.2.13.txt
index 450f7acdbf..cc0739e646 100644
--- a/docs/releases/2.2.13.txt
+++ b/docs/releases/2.2.13.txt
@@ -4,9 +4,12 @@ Django 2.2.13 release notes
*Expected June 3, 2020*
-Django 2.2.13 fixes two security issues and a bug in 2.2.12.
+Django 2.2.13 fixes two security issues and a regression in 2.2.12.
Bugfixes
========
-* ...
+* Fixed a regression in Django 2.2.12 that affected translation loading for
+ apps providing translations for territorial language variants as well as a
+ generic language, where the project has different plural equations for the
+ language (:ticket:`31570`).
diff --git a/docs/releases/3.0.7.txt b/docs/releases/3.0.7.txt
index c7bc3730fd..b38a8d8059 100644
--- a/docs/releases/3.0.7.txt
+++ b/docs/releases/3.0.7.txt
@@ -25,3 +25,8 @@ Bugfixes
* Fixed a regression in Django 3.0 where all resolved ``Subquery()``
expressions were considered equal (:ticket:`31607`).
+
+* Fixed a regression in Django 3.0.5 that affected translation loading for apps
+ providing translations for territorial language variants as well as a generic
+ language, where the project has different plural equations for the language
+ (:ticket:`31570`).
diff --git a/tests/i18n/loading/en/LC_MESSAGES/django.mo b/tests/i18n/loading/en/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..f666550adb
--- /dev/null
+++ b/tests/i18n/loading/en/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/loading/en/LC_MESSAGES/django.po b/tests/i18n/loading/en/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..d43d83e34a
--- /dev/null
+++ b/tests/i18n/loading/en/LC_MESSAGES/django.po
@@ -0,0 +1,23 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-13 08:42+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: trans/tests.py:16
+msgid "local country person"
+msgstr "local country person"
diff --git a/tests/i18n/loading/en_AU/LC_MESSAGES/django.mo b/tests/i18n/loading/en_AU/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..98b016bc6c
--- /dev/null
+++ b/tests/i18n/loading/en_AU/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/loading/en_AU/LC_MESSAGES/django.po b/tests/i18n/loading/en_AU/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..ec21ac899d
--- /dev/null
+++ b/tests/i18n/loading/en_AU/LC_MESSAGES/django.po
@@ -0,0 +1,23 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-13 08:42+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: trans/tests.py:16
+msgid "local country person"
+msgstr "aussie"
diff --git a/tests/i18n/loading/en_CA/LC_MESSAGES/django.mo b/tests/i18n/loading/en_CA/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..4d6da00f65
--- /dev/null
+++ b/tests/i18n/loading/en_CA/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/loading/en_CA/LC_MESSAGES/django.po b/tests/i18n/loading/en_CA/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..06e52a4c55
--- /dev/null
+++ b/tests/i18n/loading/en_CA/LC_MESSAGES/django.po
@@ -0,0 +1,22 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-13 08:42+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: trans/tests.py:16
+msgid "local country person"
+msgstr "canuck"
diff --git a/tests/i18n/loading/en_NZ/LC_MESSAGES/django.mo b/tests/i18n/loading/en_NZ/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..f71850a5b1
--- /dev/null
+++ b/tests/i18n/loading/en_NZ/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/loading/en_NZ/LC_MESSAGES/django.po b/tests/i18n/loading/en_NZ/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..41b7499291
--- /dev/null
+++ b/tests/i18n/loading/en_NZ/LC_MESSAGES/django.po
@@ -0,0 +1,22 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-13 08:42+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: trans/tests.py:16
+msgid "local country person"
+msgstr "kiwi"
diff --git a/tests/i18n/loading_app/__init__.py b/tests/i18n/loading_app/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/i18n/loading_app/__init__.py
diff --git a/tests/i18n/loading_app/apps.py b/tests/i18n/loading_app/apps.py
new file mode 100644
index 0000000000..b4cdece232
--- /dev/null
+++ b/tests/i18n/loading_app/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class LoadingAppConfig(AppConfig):
+ name = 'loading_app'
diff --git a/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mo b/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..71cbdf3e9d
--- /dev/null
+++ b/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.po b/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..e1422f19da
--- /dev/null
+++ b/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.po
@@ -0,0 +1,25 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-13 11:39+0300\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: apps.py:8
+msgid ""
+"An app with its own translation files, with one for 'en' but not the "
+"regional dialects of English"
+msgstr ""
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 8f07c14247..feca7b856f 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -384,6 +384,51 @@ class TranslationTests(SimpleTestCase):
self.assertIs(get_language_bidi(), True)
+class TranslationLoadingTests(SimpleTestCase):
+ def setUp(self):
+ """Clear translation state."""
+ self._old_language = get_language()
+ self._old_translations = trans_real._translations
+ deactivate()
+ trans_real._translations = {}
+
+ def tearDown(self):
+ trans_real._translations = self._old_translations
+ activate(self._old_language)
+
+ @override_settings(
+ USE_I18N=True,
+ LANGUAGE_CODE='en',
+ LANGUAGES=[
+ ('en', 'English'),
+ ('en-ca', 'English (Canada)'),
+ ('en-nz', 'English (New Zealand)'),
+ ('en-au', 'English (Australia)'),
+ ],
+ LOCALE_PATHS=[os.path.join(here, 'loading')],
+ INSTALLED_APPS=['i18n.loading_app'],
+ )
+ def test_translation_loading(self):
+ """
+ "loading_app" does not have translations for all languages provided by
+ "loading". Catalogs are merged correctly.
+ """
+ tests = [
+ ('en', 'local country person'),
+ ('en_AU', 'aussie'),
+ ('en_NZ', 'kiwi'),
+ ('en_CA', 'canuck'),
+ ]
+ # Load all relevant translations.
+ for language, _ in tests:
+ activate(language)
+ # Catalogs are merged correctly.
+ for language, nickname in tests:
+ with self.subTest(language=language):
+ activate(language)
+ self.assertEqual(gettext('local country person'), nickname)
+
+
class TranslationThreadSafetyTests(SimpleTestCase):
def setUp(self):