feat: add page shell, preferences and translations
Base layout with top bar, role-based menu, profile menu and phone layout; theme, language and German form of address kept in cookies; German formal, German informal and English text; Fluent avatar bundled in the image by a Node build stage; placeholder pages for the Publisher and Admin groups. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N3t4WL7bd9bdHHNjEsxzqC
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from django.utils import translation
|
||||
from django.utils.cache import patch_vary_headers
|
||||
|
||||
from . import preferences
|
||||
|
||||
|
||||
class PreferencesMiddleware:
|
||||
"""Read the preference cookies and activate the language for this request (AD-15)."""
|
||||
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
prefs = preferences.from_request(request)
|
||||
request.preferences = prefs
|
||||
request.LANGUAGE_CODE = prefs.language_code
|
||||
translation.activate(prefs.language_code)
|
||||
try:
|
||||
response = self.get_response(request)
|
||||
finally:
|
||||
translation.deactivate()
|
||||
response.headers.setdefault("Content-Language", prefs.language)
|
||||
patch_vary_headers(response, ("Cookie", "Accept-Language"))
|
||||
return response
|
||||
Reference in New Issue
Block a user