wip, claude + docker-compose modifications
This commit is contained in:
11
app.py
11
app.py
@@ -12,9 +12,15 @@ SUPPORTED_LANGS = ["fr", "en", "de"]
|
||||
|
||||
|
||||
def _select_locale():
|
||||
# 1. Explicit session override (set via flag switcher)
|
||||
lang = flask_session.get("lang")
|
||||
if lang in SUPPORTED_LANGS:
|
||||
return lang
|
||||
# 2. Authenticated user's stored preference
|
||||
if current_user.is_authenticated and current_user.language in SUPPORTED_LANGS:
|
||||
flask_session["lang"] = current_user.language
|
||||
return current_user.language
|
||||
# 3. Browser Accept-Language header
|
||||
return request.accept_languages.best_match(SUPPORTED_LANGS) or "en"
|
||||
|
||||
|
||||
@@ -74,11 +80,13 @@ def create_app(config_class=Config):
|
||||
def load_user(user_id):
|
||||
return db.session.get(User, int(user_id))
|
||||
|
||||
from blueprints.admin import admin_bp
|
||||
from blueprints.auth import auth_bp
|
||||
from blueprints.dashboard import dashboard_bp
|
||||
from blueprints.equipment import equipment_bp
|
||||
from blueprints.sessions import sessions_bp
|
||||
from blueprints.analyses import analyses_bp
|
||||
app.register_blueprint(admin_bp)
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(dashboard_bp)
|
||||
app.register_blueprint(equipment_bp)
|
||||
@@ -116,6 +124,9 @@ def create_app(config_class=Config):
|
||||
def set_lang(lang: str):
|
||||
if lang in SUPPORTED_LANGS:
|
||||
flask_session["lang"] = lang
|
||||
if current_user.is_authenticated:
|
||||
current_user.language = lang
|
||||
db.session.commit()
|
||||
return redirect(request.referrer or "/")
|
||||
|
||||
@app.route("/")
|
||||
|
||||
Reference in New Issue
Block a user