mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
Fixed #24063 -- Allowed locale variants supported by gettext.
The locale code can contain a variant after @, so allowed that.
This commit is contained in:
parent
9d6914da66
commit
76d26d8922
@ -43,9 +43,12 @@ accept_language_re = re.compile(r'''
|
||||
(?:\s*,\s*|$) # Multiple accepts per header.
|
||||
''', re.VERBOSE)
|
||||
|
||||
language_code_re = re.compile(r'^[a-z]{1,8}(?:-[a-z0-9]{1,8})*$', re.IGNORECASE)
|
||||
language_code_re = re.compile(
|
||||
r'^[a-z]{1,8}(?:-[a-z0-9]{1,8})*(?:@[a-z0-9]{1,20})?$',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
|
||||
language_code_prefix_re = re.compile(r'^/([\w@-]+)(/|$)')
|
||||
|
||||
|
||||
@receiver(setting_changed)
|
||||
|
@ -162,6 +162,10 @@ Internationalization
|
||||
* The :func:`django.utils.timezone.make_aware` function gained an ``is_dst``
|
||||
argument to help resolve ambiguous times during DST transitions.
|
||||
|
||||
* You can now use locale variants supported by gettext. These are usually used
|
||||
for languages which can be written in different scripts, for example Latin
|
||||
and Cyrillic (e.g. ``be@latin``).
|
||||
|
||||
Management Commands
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -1420,9 +1420,18 @@ class CountrySpecificLanguageTests(TestCase):
|
||||
self.assertTrue(check_for_language('en'))
|
||||
self.assertTrue(check_for_language('en-us'))
|
||||
self.assertTrue(check_for_language('en-US'))
|
||||
self.assertTrue(check_for_language('be'))
|
||||
self.assertTrue(check_for_language('be@latin'))
|
||||
self.assertTrue(check_for_language('sr-RS@latin'))
|
||||
self.assertTrue(check_for_language('sr-RS@12345'))
|
||||
self.assertFalse(check_for_language('en-ü'))
|
||||
self.assertFalse(check_for_language('en\x00'))
|
||||
self.assertFalse(check_for_language(None))
|
||||
self.assertFalse(check_for_language('be@ '))
|
||||
# Specifying encoding is not supported (Django enforces UTF-8)
|
||||
self.assertFalse(check_for_language('tr-TR.UTF-8'))
|
||||
self.assertFalse(check_for_language('tr-TR.UTF8'))
|
||||
self.assertFalse(check_for_language('de-DE.utf-8'))
|
||||
|
||||
def test_get_language_from_request(self):
|
||||
# issue 19919
|
||||
|
Loading…
Reference in New Issue
Block a user