Skip to content

Commit

Permalink
fix: babel determine_locale enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
20cents committed Nov 5, 2024
1 parent 84dd928 commit 48787b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 48787b5

Please sign in to comment.