Skip to content

Commit

Permalink
fix: first language visit
Browse files Browse the repository at this point in the history
This fix is based in the method `get_language_cookie` default value.
https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/lang_pref/helpers.py#L9

So in the first visit if the cookie doesnt exist, the language would be the configure by settings using
`LANGUAGE_CODE`.If it is not defined, then would be `None` that is the default of the method.
  • Loading branch information
johanseto committed Dec 7, 2023
1 parent 6427bbf commit 98e5b66
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/lang_pref/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Middleware for Language Preferences
"""


from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
from django.utils.translation import LANGUAGE_SESSION_KEY
from django.utils.translation.trans_real import parse_accept_lang_header
Expand All @@ -29,7 +29,7 @@ def process_request(self, request):
If a user's UserPreference contains a language preference, use the user's preference.
Save the current language preference cookie as the user's preferred language.
"""
cookie_lang = lang_pref_helpers.get_language_cookie(request)
cookie_lang = lang_pref_helpers.get_language_cookie(request, getattr(settings, "LANGUAGE_CODE", None))
if cookie_lang:
if request.user.is_authenticated:
# DarkLangMiddleware will take care of this so don't change anything
Expand Down

0 comments on commit 98e5b66

Please sign in to comment.