|
@@ -175,7 +175,43 @@ class BasicExtractorTests(ExtractorTests):
|
|
|
self.assertIn("processing locale de", out.getvalue())
|
|
|
self.assertIs(Path(self.PO_FILE).exists(), True)
|
|
|
|
|
|
- def test_invalid_locale(self):
|
|
|
+ def test_valid_locale_with_country(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["en_GB"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertNotIn("invalid locale en_GB", out.getvalue())
|
|
|
+ self.assertIn("processing locale en_GB", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/en_GB/LC_MESSAGES/django.po").exists(), True)
|
|
|
+
|
|
|
+ def test_valid_locale_tachelhit_latin_morocco(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["shi_Latn_MA"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertNotIn("invalid locale shi_Latn_MA", out.getvalue())
|
|
|
+ self.assertIn("processing locale shi_Latn_MA", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/shi_Latn_MA/LC_MESSAGES/django.po").exists(), True)
|
|
|
+
|
|
|
+ def test_valid_locale_private_subtag(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["nl_NL-x-informal"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertNotIn("invalid locale nl_NL-x-informal", out.getvalue())
|
|
|
+ self.assertIn("processing locale nl_NL-x-informal", out.getvalue())
|
|
|
+ self.assertIs(
|
|
|
+ Path("locale/nl_NL-x-informal/LC_MESSAGES/django.po").exists(), True
|
|
|
+ )
|
|
|
+
|
|
|
+ def test_invalid_locale_uppercase(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command("makemessages", locale=["PL"], stdout=out, verbosity=1)
|
|
|
+ self.assertIn("invalid locale PL, did you mean pl?", out.getvalue())
|
|
|
+ self.assertNotIn("processing locale pl", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/pl/LC_MESSAGES/django.po").exists(), False)
|
|
|
+
|
|
|
+ def test_invalid_locale_hyphen(self):
|
|
|
out = StringIO()
|
|
|
management.call_command(
|
|
|
"makemessages", locale=["pl-PL"], stdout=out, verbosity=1
|
|
@@ -184,6 +220,52 @@ class BasicExtractorTests(ExtractorTests):
|
|
|
self.assertNotIn("processing locale pl-PL", out.getvalue())
|
|
|
self.assertIs(Path("locale/pl-PL/LC_MESSAGES/django.po").exists(), False)
|
|
|
|
|
|
+ def test_invalid_locale_lower_country(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["pl_pl"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertIn("invalid locale pl_pl, did you mean pl_PL?", out.getvalue())
|
|
|
+ self.assertNotIn("processing locale pl_pl", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/pl_pl/LC_MESSAGES/django.po").exists(), False)
|
|
|
+
|
|
|
+ def test_invalid_locale_private_subtag(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["nl-nl-x-informal"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertIn(
|
|
|
+ "invalid locale nl-nl-x-informal, did you mean nl_NL-x-informal?",
|
|
|
+ out.getvalue(),
|
|
|
+ )
|
|
|
+ self.assertNotIn("processing locale nl-nl-x-informal", out.getvalue())
|
|
|
+ self.assertIs(
|
|
|
+ Path("locale/nl-nl-x-informal/LC_MESSAGES/django.po").exists(), False
|
|
|
+ )
|
|
|
+
|
|
|
+ def test_invalid_locale_plus(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command(
|
|
|
+ "makemessages", locale=["en+GB"], stdout=out, verbosity=1
|
|
|
+ )
|
|
|
+ self.assertIn("invalid locale en+GB, did you mean en_GB?", out.getvalue())
|
|
|
+ self.assertNotIn("processing locale en+GB", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/en+GB/LC_MESSAGES/django.po").exists(), False)
|
|
|
+
|
|
|
+ def test_invalid_locale_end_with_underscore(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command("makemessages", locale=["en_"], stdout=out, verbosity=1)
|
|
|
+ self.assertIn("invalid locale en_", out.getvalue())
|
|
|
+ self.assertNotIn("processing locale en_", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/en_/LC_MESSAGES/django.po").exists(), False)
|
|
|
+
|
|
|
+ def test_invalid_locale_start_with_underscore(self):
|
|
|
+ out = StringIO()
|
|
|
+ management.call_command("makemessages", locale=["_en"], stdout=out, verbosity=1)
|
|
|
+ self.assertIn("invalid locale _en", out.getvalue())
|
|
|
+ self.assertNotIn("processing locale _en", out.getvalue())
|
|
|
+ self.assertIs(Path("locale/_en/LC_MESSAGES/django.po").exists(), False)
|
|
|
+
|
|
|
def test_comments_extractor(self):
|
|
|
management.call_command("makemessages", locale=[LOCALE], verbosity=0)
|
|
|
self.assertTrue(os.path.exists(self.PO_FILE))
|