From f8a367655597817ed839efd7c913ee189d9c1ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Thu, 7 Apr 2022 13:56:02 +0200 Subject: [PATCH] only set session (cookie) lang on changes --- src/capport/api/lang.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/capport/api/lang.py b/src/capport/api/lang.py index 5b9b033..e3c1911 100644 --- a/src/capport/api/lang.py +++ b/src/capport/api/lang.py @@ -1,9 +1,10 @@ from __future__ import annotations +import os.path import re import typing + import quart -import os.path from .app import app @@ -53,7 +54,8 @@ def detect_language(): if 'setlang' in r.args: lang = r.args.get('setlang').strip().lower() if lang and _VALID_LANGUAGE_NAMES.match(lang): - s['lang'] = lang + if s.get('lang') != lang: + s['lang'] = lang g.langs = [lang] return else: