1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35973 -- Improved makemessages locale validation to handle numeric region codes.

This commit is contained in:
Juan Pablo Mallarino 2024-12-05 08:14:59 -05:00 committed by Sarah Boyce
parent d345e5b5f8
commit 08feaae588
2 changed files with 10 additions and 1 deletions

View File

@ -40,7 +40,7 @@ def check_programs(*programs):
def is_valid_locale(locale): 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 @total_ordering

View File

@ -179,6 +179,15 @@ class BasicExtractorTests(ExtractorTests):
self.assertIn("processing 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) 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): def test_valid_locale_tachelhit_latin_morocco(self):
out = StringIO() out = StringIO()
management.call_command( management.call_command(