2
0

only set session (cookie) lang on changes

This commit is contained in:
Stefan Bühler 2022-04-07 13:56:02 +02:00
parent 7420b4107e
commit f8a3676555

View File

@ -1,9 +1,10 @@
from __future__ import annotations from __future__ import annotations
import os.path
import re import re
import typing import typing
import quart import quart
import os.path
from .app import app from .app import app
@ -53,6 +54,7 @@ def detect_language():
if 'setlang' in r.args: if 'setlang' in r.args:
lang = r.args.get('setlang').strip().lower() lang = r.args.get('setlang').strip().lower()
if lang and _VALID_LANGUAGE_NAMES.match(lang): if lang and _VALID_LANGUAGE_NAMES.match(lang):
if s.get('lang') != lang:
s['lang'] = lang s['lang'] = lang
g.langs = [lang] g.langs = [lang]
return return