mirror of
https://github.com/django/django.git
synced 2025-03-12 10:22:37 +00:00
Fixed #33078 -- Added support for language regions in i18n_patterns().
This commit is contained in:
parent
4f7bbc6138
commit
d3f4c2b95d
@ -43,7 +43,7 @@ language_code_re = _lazy_re_compile(
|
|||||||
re.IGNORECASE
|
re.IGNORECASE
|
||||||
)
|
)
|
||||||
|
|
||||||
language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+)?)(/|$)')
|
language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+){0,2})(/|$)')
|
||||||
|
|
||||||
|
|
||||||
@receiver(setting_changed)
|
@receiver(setting_changed)
|
||||||
|
@ -183,7 +183,8 @@ Generic Views
|
|||||||
Internationalization
|
Internationalization
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
* ...
|
* The :func:`~django.conf.urls.i18n.i18n_patterns` function now supports
|
||||||
|
languages with both scripts and regions.
|
||||||
|
|
||||||
Logging
|
Logging
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -1593,11 +1593,15 @@ class MiscTests(SimpleTestCase):
|
|||||||
@override_settings(
|
@override_settings(
|
||||||
LANGUAGES=[
|
LANGUAGES=[
|
||||||
('en', 'English'),
|
('en', 'English'),
|
||||||
|
('en-latn-us', 'Latin English'),
|
||||||
|
('en-Latn-US', 'BCP 47 case format'),
|
||||||
('de', 'German'),
|
('de', 'German'),
|
||||||
('de-1996', 'German, orthography of 1996'),
|
('de-1996', 'German, orthography of 1996'),
|
||||||
('de-at', 'Austrian German'),
|
('de-at', 'Austrian German'),
|
||||||
|
('de-ch-1901', 'German, Swiss variant, traditional orthography'),
|
||||||
('i-mingo', 'Mingo'),
|
('i-mingo', 'Mingo'),
|
||||||
('kl-tunumiit', 'Tunumiisiut'),
|
('kl-tunumiit', 'Tunumiisiut'),
|
||||||
|
('nan-hani-tw', 'Hanji'),
|
||||||
('pl', 'Polish'),
|
('pl', 'Polish'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -1609,13 +1613,17 @@ class MiscTests(SimpleTestCase):
|
|||||||
('/xyz/', None),
|
('/xyz/', None),
|
||||||
('/en/', 'en'),
|
('/en/', 'en'),
|
||||||
('/en-gb/', 'en'),
|
('/en-gb/', 'en'),
|
||||||
|
('/en-latn-us/', 'en-latn-us'),
|
||||||
|
('/en-Latn-US/', 'en-Latn-US'),
|
||||||
('/de/', 'de'),
|
('/de/', 'de'),
|
||||||
('/de-1996/', 'de-1996'),
|
('/de-1996/', 'de-1996'),
|
||||||
('/de-at/', 'de-at'),
|
('/de-at/', 'de-at'),
|
||||||
('/de-ch/', 'de'),
|
('/de-ch/', 'de'),
|
||||||
('/de-simple-page/', None),
|
('/de-ch-1901/', 'de-ch-1901'),
|
||||||
|
('/de-simple-page-test/', None),
|
||||||
('/i-mingo/', 'i-mingo'),
|
('/i-mingo/', 'i-mingo'),
|
||||||
('/kl-tunumiit/', 'kl-tunumiit'),
|
('/kl-tunumiit/', 'kl-tunumiit'),
|
||||||
|
('/nan-hani-tw/', 'nan-hani-tw'),
|
||||||
]
|
]
|
||||||
for path, language in tests:
|
for path, language in tests:
|
||||||
with self.subTest(path=path):
|
with self.subTest(path=path):
|
||||||
@ -1824,7 +1832,7 @@ class UnprefixedDefaultLanguageTests(SimpleTestCase):
|
|||||||
|
|
||||||
def test_page_with_dash(self):
|
def test_page_with_dash(self):
|
||||||
# A page starting with /de* shouldn't match the 'de' language code.
|
# A page starting with /de* shouldn't match the 'de' language code.
|
||||||
response = self.client.get('/de-simple-page/')
|
response = self.client.get('/de-simple-page-test/')
|
||||||
self.assertEqual(response.content, b'Yes')
|
self.assertEqual(response.content, b'Yes')
|
||||||
|
|
||||||
def test_no_redirect_on_404(self):
|
def test_no_redirect_on_404(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user