[Mpuls-commits] r4119 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 3 16:12:30 CET 2010


Author: bh
Date: 2010-11-03 16:12:29 +0100 (Wed, 03 Nov 2010)
New Revision: 4119

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/base.py
Log:
* mpulsweb/lib/base.py (BaseController.__before__): Simply pass
all languages from the request plus the default language to the
set_lang function instead of trying to figure out in __before__
which of them actually works.  This way the translations actually
work even if 'de' is not the first element in the list of
languages in the request.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-11-03 14:29:04 UTC (rev 4118)
+++ base/trunk/ChangeLog	2010-11-03 15:12:29 UTC (rev 4119)
@@ -1,3 +1,12 @@
+2010-11-03  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/base.py (BaseController.__before__): Simply pass
+	all languages from the request plus the default language to the
+	set_lang function instead of trying to figure out in __before__
+	which of them actually works.  This way the translations actually
+	work even if 'de' is not the first element in the list of
+	languages in the request.
+
 2010-11-03  Torsten Irlaender <torsten at intevation.de>
 
 	Issue1314:

Modified: base/trunk/mpulsweb/lib/base.py
===================================================================
--- base/trunk/mpulsweb/lib/base.py	2010-11-03 14:29:04 UTC (rev 4118)
+++ base/trunk/mpulsweb/lib/base.py	2010-11-03 15:12:29 UTC (rev 4119)
@@ -156,29 +156,12 @@
         except KeyError:
             pass
 
-        # Set language for translation based an browser setting. Default
-        # locales.
-        # TODO: pylons.i18n.translation (_get_translator) still tries to load
-        # language files for "waskaweb". It seems to be defined in
-        # conf['pylons.package']. I do not know how this var gets set during
-        # application init.
+        # Set language for translation based on browser setting. Add a
+        # default language based on the server's locale settings.
         deflang = locale.getlocale()[0]
-        for lang in request.languages:
-            try:
-                log.debug('Trying to set lang to %s' % lang)
-                set_lang(lang)
-                break
-            except Exception, e:
-                log.debug('Can not set lang to %s' % lang)
-        else:
-            log.debug('Trying to set lang to default: %s' % deflang)
-            try:
-                lang = deflang
-                set_lang(lang)
-            except:
-                log.exception(e)
-                raise
-        log.debug('Ok. Lang set to %s' % lang)
+        all_languages = request.languages + [deflang]
+        set_lang(all_languages)
+        log.debug('Language set to %s', all_languages)
 
         # Check if the user is already authorized.
         # If not then redirect the user to the login page



More information about the Mpuls-commits mailing list