diff options
author | Claude Paroz <claude@2xlibre.net> | 2022-07-23 11:44:45 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-07-25 08:45:46 +0200 |
commit | f2dd652245987465754c7242b60ccaba03a20f06 (patch) | |
tree | 8c58275140de71f6cfe90b4142a7573c39c0244a /tests/view_tests | |
parent | 9ba2e8821fd88205f029b0e515015ddfb938ba12 (diff) | |
download | django-f2dd652245987465754c7242b60ccaba03a20f06.tar.gz |
Fixed #33863 -- Fixed JavaScriptCatalog with more than 1 level of fallback translations.
Co-authored-by: Carlos Mermingas <cmermingas@gmail.com>
Diffstat (limited to 'tests/view_tests')
-rw-r--r-- | tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.mo | bin | 0 -> 444 bytes | |||
-rw-r--r-- | tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.po | 20 | ||||
-rw-r--r-- | tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.mo | bin | 0 -> 326 bytes | |||
-rw-r--r-- | tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.po | 20 | ||||
-rw-r--r-- | tests/view_tests/tests/test_i18n.py | 21 | ||||
-rw-r--r-- | tests/view_tests/urls.py | 1 |
6 files changed, 62 insertions, 0 deletions
diff --git a/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.mo b/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.mo Binary files differnew file mode 100644 index 0000000000..181b61fd9c --- /dev/null +++ b/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.mo diff --git a/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.po b/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.po new file mode 100644 index 0000000000..12e0c367ba --- /dev/null +++ b/tests/view_tests/custom_locale_path/es/LC_MESSAGES/djangojs.po @@ -0,0 +1,20 @@ +# 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. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-09-15 16:45+0200\n" +"PO-Revision-Date: 2010-05-12 12:57-0300\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: media/js/translate.js:1 +msgid "custom_locale_path: this is to be translated" +msgstr "custom_locale_path: esto tiene que ser traducido" diff --git a/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.mo b/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.mo Binary files differnew file mode 100644 index 0000000000..045c5ec583 --- /dev/null +++ b/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.mo diff --git a/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.po b/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.po new file mode 100644 index 0000000000..22c708a891 --- /dev/null +++ b/tests/view_tests/custom_locale_path/es_MX/LC_MESSAGES/djangojs.po @@ -0,0 +1,20 @@ +# 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. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-09-15 16:45+0200\n" +"PO-Revision-Date: 2010-05-12 12:57-0300\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: media/js/translate.js:1 +msgid "custom_locale_path: this is to be translated" +msgstr "" diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index 3aacded7c6..aff920c2c4 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -344,6 +344,27 @@ class I18NViewTests(SimpleTestCase): self.assertContains(response, "il faut le traduire") self.assertNotContains(response, "Untranslated string") + def test_jsi18n_fallback_language_with_custom_locale_dir(self): + """ + The fallback language works when there are several levels of fallback + translation catalogs. + """ + locale_paths = [ + path.join( + path.dirname(path.dirname(path.abspath(__file__))), + "custom_locale_path", + ), + ] + with self.settings(LOCALE_PATHS=locale_paths), override("es_MX"): + response = self.client.get("/jsi18n/") + self.assertContains( + response, "custom_locale_path: esto tiene que ser traducido" + ) + response = self.client.get("/jsi18n_no_packages/") + self.assertContains( + response, "custom_locale_path: esto tiene que ser traducido" + ) + def test_i18n_fallback_language_plural(self): """ The fallback to a language with less plural forms maintains the real diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py index cec156b5da..c9a5c28573 100644 --- a/tests/view_tests/urls.py +++ b/tests/view_tests/urls.py @@ -31,6 +31,7 @@ urlpatterns = [ # i18n views path("i18n/", include("django.conf.urls.i18n")), path("jsi18n/", i18n.JavaScriptCatalog.as_view(packages=["view_tests"])), + path("jsi18n_no_packages/", i18n.JavaScriptCatalog.as_view()), path("jsi18n/app1/", i18n.JavaScriptCatalog.as_view(packages=["view_tests.app1"])), path("jsi18n/app2/", i18n.JavaScriptCatalog.as_view(packages=["view_tests.app2"])), path("jsi18n/app5/", i18n.JavaScriptCatalog.as_view(packages=["view_tests.app5"])), |