From d9fa6c7858c2b921c3da38b68f15af475b3f2cdf Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 21 Aug 2020 16:40:19 +0200 Subject: [PATCH] Fix api18n : it should return a wrapper and not the callback directly. Current code led to some weird incorrect locale sometimes --- moulinette/interfaces/api.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index afa6f081..03a77959 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -776,12 +776,14 @@ class Interface(BaseInterface): # Attempt to retrieve and set locale def api18n(callback): - try: - locale = request.params.pop("locale") - except KeyError: - locale = m18n.default_locale - m18n.set_locale(locale) - return callback + def wrapper(*args, **kwargs): + try: + locale = request.params.pop("locale") + except KeyError: + locale = m18n.default_locale + m18n.set_locale(locale) + return callback(*args, **kwargs) + return wrapper # Install plugins app.install(filter_csrf)