🐛 fix(i18n): handle missing session in locale resolution
- add exception handling to manage cases where session is not in request scope
This commit is contained in:
parent
cc7c75ba33
commit
21d7c1e9a6
1 changed files with 7 additions and 3 deletions
|
|
@ -325,9 +325,13 @@ translations: Dict[str, Dict[str, str]] = {
|
|||
|
||||
def resolve_locale(request) -> str:
|
||||
"""Detect locale from session override or Accept-Language; default to de."""
|
||||
try:
|
||||
if "session" in request.scope:
|
||||
session_lang = request.session.get("lang")
|
||||
if session_lang in AVAILABLE_LANGUAGES:
|
||||
return session_lang
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
accept = request.headers.get("accept-language", "")
|
||||
for part in accept.split(","):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue