summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/management/commands/makemessages.py2
-rw-r--r--tests/i18n/test_extraction.py9
2 files changed, 10 insertions, 1 deletions
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 076667d41a..23ad424c5c 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -40,7 +40,7 @@ def check_programs(*programs):
def is_valid_locale(locale):
- return re.match(r"^[a-z]+$", locale) or re.match(r"^[a-z]+_[A-Z].*$", locale)
+ return re.match(r"^[a-z]+$", locale) or re.match(r"^[a-z]+_[A-Z0-9].*$", locale)
@total_ordering
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index 7aa600c4c1..e4a6260c33 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -179,6 +179,15 @@ class BasicExtractorTests(ExtractorTests):
self.assertIn("processing locale en_GB", out.getvalue())
self.assertIs(Path("locale/en_GB/LC_MESSAGES/django.po").exists(), True)
+ def test_valid_locale_with_numeric_region_code(self):
+ out = StringIO()
+ management.call_command(
+ "makemessages", locale=["ar_002"], stdout=out, verbosity=1
+ )
+ self.assertNotIn("invalid locale ar_002", out.getvalue())
+ self.assertIn("processing locale ar_002", out.getvalue())
+ self.assertIs(Path("locale/ar_002/LC_MESSAGES/django.po").exists(), True)
+
def test_valid_locale_tachelhit_latin_morocco(self):
out = StringIO()
management.call_command(