Fix api18n : it should return a wrapper and not the callback directly. Current code led to some weird incorrect locale sometimes

This commit is contained in:
Alexandre Aubin 2020-08-21 16:40:19 +02:00
parent dbc4716b48
commit d9fa6c7858

View file

@ -776,12 +776,14 @@ class Interface(BaseInterface):
# Attempt to retrieve and set locale
def api18n(callback):
def wrapper(*args, **kwargs):
try:
locale = request.params.pop("locale")
except KeyError:
locale = m18n.default_locale
m18n.set_locale(locale)
return callback
return callback(*args, **kwargs)
return wrapper
# Install plugins
app.install(filter_csrf)