diff options
| author | Natalia <124304+nessita@users.noreply.github.com> | 2023-09-20 17:39:01 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-22 08:55:11 +0200 |
| commit | 88992c5ac62f4170bc502adb8a9d7304ce6dccc3 (patch) | |
| tree | fee3422f529c62f8155aeff574baaef18e274dcb /tests | |
| parent | 41d82fda2a15b63bd27a6456be422c44bf43ab7b (diff) | |
[5.0.x] Fixed #34848 -- Ignored i18n_catalog.js file when building Django's translations catalog.
Backport of d7972436639bacada0f94d3b9818446343af59ad from main
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/test_extraction.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index 9e10218666..226d51ce11 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -638,6 +638,28 @@ class JavaScriptExtractorTests(ExtractorTests): _, po_contents = self._run_makemessages(domain="djangojs") self.assertMsgId("Static content inside app should be included.", po_contents) + def test_i18n_catalog_ignored_when_invoked_for_django(self): + # Create target file so it exists in the filesystem and can be ignored. + # "invoked_for_django" is True when "conf/locale" folder exists. + os.makedirs(os.path.join("conf", "locale")) + i18n_catalog_js_dir = os.path.join(os.path.curdir, "views", "templates") + os.makedirs(i18n_catalog_js_dir) + open(os.path.join(i18n_catalog_js_dir, "i18n_catalog.js"), "w").close() + + out, _ = self._run_makemessages(domain="djangojs") + self.assertIn(f"ignoring file i18n_catalog.js in {i18n_catalog_js_dir}", out) + + def test_i18n_catalog_not_ignored_when_not_invoked_for_django(self): + # Create target file so it exists in the filesystem but is NOT ignored. + # "invoked_for_django" is False when "conf/locale" folder does not exist. + self.assertIs(os.path.exists(os.path.join("conf", "locale")), False) + i18n_catalog_js = os.path.join("views", "templates", "i18n_catalog.js") + os.makedirs(os.path.dirname(i18n_catalog_js)) + open(i18n_catalog_js, "w").close() + + out, _ = self._run_makemessages(domain="djangojs") + self.assertNotIn("ignoring file i18n_catalog.js", out) + class IgnoredExtractorTests(ExtractorTests): def test_ignore_directory(self): |
