summaryrefslogtreecommitdiff
path: root/django/utils/translation
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-28 08:05:43 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-02 06:04:18 +0200
commit0e444e84f87d174713a2aef0c4f9704ce2865586 (patch)
tree5fd8693f08332b5e57765a5464b8bb66eb1d10c2 /django/utils/translation
parent191f6a9a4586b5e5f79f4f42f190e7ad4bbacc84 (diff)
Fixed #34515 -- Made LocaleMiddleware prefer language from paths when i18n patterns are used.
Regression in 94e7f471c4edef845a4fe5e3160132997b4cca81. This reverts commit 94e7f471c4edef845a4fe5e3160132997b4cca81 (refs #34069) and partly reverts commit 3b4728310a7a64f8fcc548163b0aa5f98a5c78f5. Thanks Anthony Baillard for the report. Co-Authored-By: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
Diffstat (limited to 'django/utils/translation')
-rw-r--r--django/utils/translation/__init__.py1
-rw-r--r--django/utils/translation/trans_null.py2
-rw-r--r--django/utils/translation/trans_real.py6
3 files changed, 6 insertions, 3 deletions
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 69820a2fc4..0b3f78e486 100644
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -17,7 +17,6 @@ __all__ = [
"get_language_from_request",
"get_language_info",
"get_language_bidi",
- "get_supported_language_variant",
"check_for_language",
"to_language",
"to_locale",
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index 595a705e2b..c8bfb1256e 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -53,7 +53,7 @@ def check_for_language(x):
def get_language_from_request(request, check_path=False):
- return None
+ return settings.LANGUAGE_CODE
def get_language_from_path(request):
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 46a94b99ff..872c80b00f 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -583,7 +583,11 @@ def get_language_from_request(request, check_path=False):
return get_supported_language_variant(accept_lang)
except LookupError:
continue
- return None
+
+ try:
+ return get_supported_language_variant(settings.LANGUAGE_CODE)
+ except LookupError:
+ return settings.LANGUAGE_CODE
@functools.lru_cache(maxsize=1000)