[fix] handle weights in accept language parsing - fixes w3ms en;q=1.0

This commit is contained in:
Adam Tauber 2020-03-16 00:22:15 +01:00
parent 8e727ac77f
commit baca55c94e
1 changed files with 3 additions and 0 deletions

View File

@ -178,9 +178,12 @@ flask_babel.get_translations = _get_translations
def _get_browser_language(request, lang_list):
for lang in request.headers.get("Accept-Language", "en").split(","):
if ';' in lang:
lang = lang.split(';')[0]
locale = match_language(lang, lang_list, fallback=None)
if locale is not None:
return locale
return settings['search']['default_lang'] or 'en'
@babel.localeselector