From 48787b536dd5211fc439d88b54cef9c3799163f3 Mon Sep 17 00:00:00 2001 From: Vincent Bourgeois Date: Tue, 5 Nov 2024 17:59:14 +0100 Subject: [PATCH] fix: babel determine_locale enhancements --- backend/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/app.py b/backend/app.py index 70a8e372..82c41976 100755 --- a/backend/app.py +++ b/backend/app.py @@ -59,9 +59,11 @@ def __call__(self, environ, start_response): @babel.localeselector def determine_locale(): locale = utils.getLocale() - translation_exists = locale in [ - str(translation) for translation in babel.list_translations() - ] + translation_ids = [str(translation) for translation in babel.list_translations()] + translation_exists = locale in translation_ids + if not translation_exists and "-" in locale: + locale = locale.split("-")[0] + translation_exists = locale in translation_ids if not translation_exists: default_lang = utils.getDefaultLang() locale = default_lang.id