diff --git a/evibes/middleware.py b/evibes/middleware.py index 68e624fc..1ed9e89f 100644 --- a/evibes/middleware.py +++ b/evibes/middleware.py @@ -8,6 +8,7 @@ from django.core.exceptions import DisallowedHost from django.http import HttpResponseForbidden from django.middleware.common import CommonMiddleware from django.shortcuts import redirect +from django.utils import translation from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework_simplejwt.exceptions import InvalidToken from sentry_sdk import capture_exception @@ -28,6 +29,7 @@ class CustomCommonMiddleware(CommonMiddleware): class CustomLocaleCommonMiddleware(CommonMiddleware): def process_request(self, request): request.locale = get_language_from_header(request.headers.get("Accept-Language", "")) + translation.activate(request.locale) class GrapheneJWTAuthorizationMiddleware: @@ -61,6 +63,8 @@ class GrapheneLocaleMiddleware: selected_language = get_language_from_header(accept_language) request.locale = selected_language + translation.activate(request.locale) + return next(root, info, **args)