From ed594264664f0e0aca00de4f962d267750b21fd1 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sat, 15 Oct 2011 16:46:04 -0500 Subject: [PATCH] Fixes issue662, MediaGoblin was broken by recent WebOb release. From WebOb release notes: "Accept.best_matches() is gone; use list(request.accept) or request.accept.best_match(..) instead (applies to all Accept-* headers) or similar with request.accept_language." ... seems that's what borked it... --- mediagoblin/tools/translate.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index 2c2a710d..f2990867 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -65,8 +65,6 @@ def get_locale_from_request(request): if request_form.has_key('lang'): return locale_to_lower_upper(request_form['lang']) - accept_lang_matches = request.accept_language.best_matches() - # Your routing can explicitly specify a target language matchdict = request.matchdict or {} @@ -74,12 +72,10 @@ def get_locale_from_request(request): target_lang = matchdict['locale'] elif request.session.has_key('target_lang'): target_lang = request.session['target_lang'] - # Pull the first acceptable language - elif accept_lang_matches: - target_lang = accept_lang_matches[0] - # Fall back to English + # Pull the first acceptable language or English else: - target_lang = 'en' + target_lang = request.accept.best_match( + request.accept_language, 'en') return locale_to_lower_upper(target_lang) -- 2.25.1