mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Refactor get_locale() to be cleaner
This commit is contained in:
parent
7aac597216
commit
9fcbbdc472
@ -130,8 +130,10 @@ def get_locale():
|
||||
return current_user.locale
|
||||
|
||||
locale = request.cookies.get("locale")
|
||||
if locale in locales:
|
||||
if current_user.is_authenticated:
|
||||
if locale not in locales:
|
||||
locale = request.accept_languages.best_match(locales)
|
||||
|
||||
if locale and current_user.is_authenticated:
|
||||
new_session = models.db.create_session({})()
|
||||
new_session.query(models.User) \
|
||||
.filter(models.User.username == current_user.username) \
|
||||
@ -141,7 +143,6 @@ def get_locale():
|
||||
|
||||
return locale
|
||||
|
||||
return request.accept_languages.best_match(locales)
|
||||
|
||||
|
||||
@app.route("/set-locale/", methods=["POST"])
|
||||
|
Loading…
Reference in New Issue
Block a user