modified: app.py

modified:   templates/base.html
	modified:   templates/index.html
This commit is contained in:
simon
2026-04-27 11:20:01 +02:00
parent 68a7247938
commit 0baf55d8bc
3 changed files with 11 additions and 1 deletions

8
app.py
View File

@@ -29,6 +29,14 @@ def _set_language():
g.lang = lang
g.T = TRANSLATIONS[lang]
@app.after_request
def _persist_language_cookie(response):
"""If ?lang= was in the URL, save it as a cookie so it survives navigation."""
url_lang = request.args.get("lang")
if url_lang in TRANSLATIONS:
response.set_cookie("lang", url_lang, max_age=60*60*24*365, samesite="Lax")
return response
@app.context_processor
def _inject_i18n():
return {"T": g.get("T", TRANSLATIONS["de"]), "lang": g.get("lang", "de")}