diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2020-05-28 10:26:41 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-06-01 09:27:02 +0200 |
| commit | 98fada7244f135022540ec5d2383fb0115844bb4 (patch) | |
| tree | 02d2d3da379734d5a40ef6661e62af007b1ab5a2 /tests | |
| parent | 9ce281d21f723498cf9b39dba2bfb219225bb4e3 (diff) | |
[3.1.x] 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.
Backport of dd1ca50b096bf0351819aabc862e91a9797ddaca from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/loading/en/LC_MESSAGES/django.mo | bin | 0 -> 446 bytes | |||
| -rw-r--r-- | tests/i18n/loading/en/LC_MESSAGES/django.po | 23 | ||||
| -rw-r--r-- | tests/i18n/loading/en_AU/LC_MESSAGES/django.mo | bin | 0 -> 432 bytes | |||
| -rw-r--r-- | tests/i18n/loading/en_AU/LC_MESSAGES/django.po | 23 | ||||
| -rw-r--r-- | tests/i18n/loading/en_CA/LC_MESSAGES/django.mo | bin | 0 -> 389 bytes | |||
| -rw-r--r-- | tests/i18n/loading/en_CA/LC_MESSAGES/django.po | 22 | ||||
| -rw-r--r-- | tests/i18n/loading/en_NZ/LC_MESSAGES/django.mo | bin | 0 -> 387 bytes | |||
| -rw-r--r-- | tests/i18n/loading/en_NZ/LC_MESSAGES/django.po | 22 | ||||
| -rw-r--r-- | tests/i18n/loading_app/__init__.py | 0 | ||||
| -rw-r--r-- | tests/i18n/loading_app/apps.py | 5 | ||||
| -rw-r--r-- | tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mo | bin | 0 -> 380 bytes | |||
| -rw-r--r-- | tests/i18n/loading_app/locale/en/LC_MESSAGES/django.po | 25 | ||||
| -rw-r--r-- | tests/i18n/tests.py | 45 |
13 files changed, 165 insertions, 0 deletions
diff --git a/tests/i18n/loading/en/LC_MESSAGES/django.mo b/tests/i18n/loading/en/LC_MESSAGES/django.mo Binary files differnew file mode 100644 index 0000000000..f666550adb --- /dev/null +++ b/tests/i18n/loading/en/LC_MESSAGES/django.mo 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 Binary files differnew file mode 100644 index 0000000000..98b016bc6c --- /dev/null +++ b/tests/i18n/loading/en_AU/LC_MESSAGES/django.mo 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 Binary files differnew file mode 100644 index 0000000000..4d6da00f65 --- /dev/null +++ b/tests/i18n/loading/en_CA/LC_MESSAGES/django.mo 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 Binary files differnew file mode 100644 index 0000000000..f71850a5b1 --- /dev/null +++ b/tests/i18n/loading/en_NZ/LC_MESSAGES/django.mo 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 Binary files differnew file mode 100644 index 0000000000..71cbdf3e9d --- /dev/null +++ b/tests/i18n/loading_app/locale/en/LC_MESSAGES/django.mo 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): |
