From 80d33c696a17c170816f806f03a9ef3c4b532eec Mon Sep 17 00:00:00 2001 From: Vivek Agrawal Date: Thu, 6 Jul 2023 18:26:31 +0530 Subject: [PATCH] Fix language ignorance for public API --- contentcuration/contentcuration/middleware/locale.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contentcuration/contentcuration/middleware/locale.py b/contentcuration/contentcuration/middleware/locale.py index 5d526f3b8b..965312c0fa 100644 --- a/contentcuration/contentcuration/middleware/locale.py +++ b/contentcuration/contentcuration/middleware/locale.py @@ -1,4 +1,6 @@ +from django.conf import settings from django.middleware.locale import LocaleMiddleware +from django.utils import translation LOCALE_EXEMPT = "_locale_exempt" @@ -15,6 +17,8 @@ def _is_exempt(self, obj): def process_view(self, request, callback, callback_args, callback_kwargs): if self._is_exempt(callback): setattr(request, LOCALE_EXEMPT, True) + translation.activate(settings.LANGUAGE_CODE) + request.LANGUAGE_CODE = translation.get_language() return None def process_response(self, request, response):