I have configured the open edX site to use Arabic language (rtl) which is working fine on the LMS homepage however when I navigate to the login/register page in the Authn MFE, the language switches back to English (ltr).
I’ve checked the documentation and community forums but haven’t found a solution to this specific issue.
Any guidance or suggestions ?
hi @harout7 ,
i had faced same issue. and what i conclude from my research is that language of site is taken from user pref-lang configuration .
to change site in arabic i changed function process_response in this file openedx/core/djangoapps/lang_pref/middleware.py
according to my need as i also want my whole site in arabic . hope it works for you
def process_response(self, request, response): # lint-amnesty, pylint: disable=missing-function-docstring
# If the user is logged in, check for their language preference. Also check for real user
# if current user is a masquerading user,
user_pref = None
current_user = None
if hasattr(request, 'user'):
current_user = getattr(request.user, 'real_user', request.user)
if current_user and current_user.is_authenticated:
# DarkLangMiddleware has already set this cookie
if DarkLangConfig.current().enabled and get_user_preference(current_user, DARK_LANGUAGE_KEY):
return response
anonymous_cookie_lang = getattr(request, '_anonymous_user_cookie_lang', None)
if anonymous_cookie_lang:
user_pref = anonymous_cookie_lang
set_user_preference(current_user, LANGUAGE_KEY, anonymous_cookie_lang)
else:
# Get the user's language preference
try:
user_pref = get_user_preference(current_user, LANGUAGE_KEY)
except (UserAPIRequestError, UserAPIInternalError):
# If we can't find the user preferences, then don't modify the cookie
pass
# If set, set the user_pref in the LANGUAGE_COOKIE_NAME
if user_pref and not is_request_from_mobile_app(request):
lang_pref_helpers.set_language_cookie(request, response, user_pref)
else:
lang_pref_helpers.unset_language_cookie(response)
else:
cookie_lang = lang_pref_helpers.get_language_cookie(request)
if cookie_lang:
lang_pref_helpers.set_language_cookie(request, response, cookie_lang)
else:
lang_pref_helpers.set_language_cookie(request, response, "ar")
return response
update me if it work.
thanks @vivek , I was able to test the solution by directly modifying the file in the container, and it worked ! I’m aware that these changes will be lost if I rebuild the openedx image in tutor, how can I make these changes persistent across container rebuilds ?
i don’t think these changes lost if you fork edx-platform and build image , as i am already doing this.
1 Like