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 # Attempt to retrieve and set locale
def api18n(callback): def api18n(callback):
try: def wrapper(*args, **kwargs):
locale = request.params.pop("locale") try:
except KeyError: locale = request.params.pop("locale")
locale = m18n.default_locale except KeyError:
m18n.set_locale(locale) locale = m18n.default_locale
return callback m18n.set_locale(locale)
return callback(*args, **kwargs)
return wrapper
# Install plugins # Install plugins
app.install(filter_csrf) app.install(filter_csrf)