Fall back to "en" if we don't find matching translations
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Sun, 2 Dec 2012 00:38:09 +0000 (01:38 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Sun, 2 Dec 2012 00:39:53 +0000 (01:39 +0100)
In case of no matching translations, target_lang was "None" which
blew up things. Fall back to "en" in case we don't find a
corresponding translation.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
mediagoblin/tools/translate.py

index b6b7a5274da6debe865b06897863d6d3b5d3d614..28b7aec0a8ecdfdc496a4046b1cbf4fc4ede7ff6 100644 (file)
@@ -88,7 +88,7 @@ def get_locale_from_request(request):
         # of accepted locales, and serve the best available locale rather than
         # the most preferred, or fall back to 'en' immediately.
         target_lang = request.accept_languages.best_match(
-            mg_globals.available_locales)
+            mg_globals.available_locales) or 'en'
         return locale_to_lower_upper(target_lang)
 
 SETUP_GETTEXTS = {}