from flask import g, request, session from flask_babel import Babel from objects import glob babel = Babel(glob.app) LANGUAGES = { "en": "English", "no": "Norwegian" } @babel.localeselector def get_locale(): if request.args.get("lang"): session["lang"] = request.args.get("lang") if request.args.get("lang") in LANGUAGES.keys() else "en" return session.get("lang", "en")