Updated PLANS.md, AGENTS.md, and arabic-localization.md to reflect the “foundations now, full translations later” approach and marked progress accordingly.
Implemented localization foundations across backend and frontend (locale settings/middleware, preferred language, i18n wiring, RTL support, minimal Arabic UI strings, Accept-Language). Added targeted backend and frontend tests plus a risks note for pending full translation coverage.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from django.utils import translation
|
||||
|
||||
|
||||
class UserLocaleMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
language = None
|
||||
activated = False
|
||||
user = getattr(request, "user", None)
|
||||
if user and getattr(user, "is_authenticated", False):
|
||||
language = getattr(user, "preferred_language", None)
|
||||
if language:
|
||||
translation.activate(language)
|
||||
request.LANGUAGE_CODE = language
|
||||
activated = True
|
||||
|
||||
response = self.get_response(request)
|
||||
|
||||
active_language = translation.get_language()
|
||||
if active_language:
|
||||
response["Content-Language"] = active_language
|
||||
|
||||
if activated:
|
||||
translation.deactivate()
|
||||
|
||||
return response
|
||||
Reference in New Issue
Block a user