changeset 3082:307abb1cf26a

fix for MoinMoinBugs/1.6.0LanguageIgnoreBrowserConfigurationError (thanks for Ninnnu for the patch, ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 00:13:46 +0100
parents a869096c582e
children f2564609f601
files MoinMoin/i18n/__init__.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/i18n/__init__.py	Fri Feb 22 22:51:57 2008 +0100
+++ b/MoinMoin/i18n/__init__.py	Sat Feb 23 00:13:46 2008 +0100
@@ -326,14 +326,15 @@
 
     # Or try to return one of the user browser accepted languages, if it
     # is available on this wiki...
-    return get_browser_language(request)
-
-    # Or return the wiki default language...
-    if request.cfg.language_default in available:
-        lang = request.cfg.language_default
-    # If everything else fails, read the manual... or return 'en'
-    else:
-        lang = 'en'
+    lang = get_browser_language(request)
+    if not lang:
+        available = wikiLanguages()
+        # Or return the wiki default language...
+        if request.cfg.language_default in available:
+            lang = request.cfg.language_default
+        # If everything else fails, read the manual... or return 'en'
+        else:
+            lang = 'en'
     return lang
 
 
@@ -374,8 +375,9 @@
 
 def get_browser_language(request):
     """
-    Return the language that is supported by wiki and what user browser
-    would prefer to get. Return nothing if there is no such language.
+    Return the language that is supported by wiki and what user browser 
+    would prefer to get. Return empty string if there is no such language
+    or language_ignore_browser is true.
 
     @param request: the request object
     @rtype: string
@@ -386,3 +388,4 @@
         for lang in browserLanguages(request):
             if lang in available:
                 return lang
+    return ''