Support for older webobs and newer webobs both in accept language mess :)
This commit is contained in:
parent
ed59426466
commit
4715091970
@ -74,8 +74,17 @@ def get_locale_from_request(request):
|
||||
target_lang = request.session['target_lang']
|
||||
# Pull the first acceptable language or English
|
||||
else:
|
||||
target_lang = request.accept.best_match(
|
||||
request.accept_language, 'en')
|
||||
# WebOb recently changed how it handles determining best language.
|
||||
# Here's a compromise commit that handles either/or...
|
||||
if hasattr(request.accept_language, "best_matches"):
|
||||
accept_lang_matches = request.accept_language.best_matches()
|
||||
if accept_lang_matches:
|
||||
target_lang = accept_lang_matches[0]
|
||||
else:
|
||||
target_lang = 'en'
|
||||
else:
|
||||
target_lang = request.accept.best_match(
|
||||
request.accept_language, 'en')
|
||||
|
||||
return locale_to_lower_upper(target_lang)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user