mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34515 -- Made LocaleMiddleware prefer language from paths when i18n patterns are used.
Regression in94e7f471c4. This reverts commit94e7f471c4(refs #34069) and partly reverts commit3b4728310a. Thanks Anthony Baillard for the report. Co-Authored-By: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
This commit is contained in:
@@ -431,6 +431,27 @@ class URLResponseTests(URLTestCaseBase):
|
||||
self.assertEqual(response.context["LANGUAGE_CODE"], "nl")
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF="i18n.urls_default_unprefixed", LANGUAGE_CODE="nl")
|
||||
class URLPrefixedFalseTranslatedTests(URLTestCaseBase):
|
||||
def test_translated_path_unprefixed_language_other_than_accepted_header(self):
|
||||
response = self.client.get("/gebruikers/", headers={"accept-language": "en"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_translated_path_unprefixed_language_other_than_cookie_language(self):
|
||||
self.client.cookies.load({settings.LANGUAGE_COOKIE_NAME: "en"})
|
||||
response = self.client.get("/gebruikers/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_translated_path_prefixed_language_other_than_accepted_header(self):
|
||||
response = self.client.get("/en/users/", headers={"accept-language": "nl"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_translated_path_prefixed_language_other_than_cookie_language(self):
|
||||
self.client.cookies.load({settings.LANGUAGE_COOKIE_NAME: "nl"})
|
||||
response = self.client.get("/en/users/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class URLRedirectWithScriptAliasTests(URLTestCaseBase):
|
||||
"""
|
||||
#21579 - LocaleMiddleware should respect the script prefix.
|
||||
|
||||
Reference in New Issue
Block a user