[Mpuls-commits] r2946 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 9 15:13:16 CEST 2010


Author: torsten
Date: 2010-06-09 15:13:13 +0200 (Wed, 09 Jun 2010)
New Revision: 2946

Modified:
   base/trunk/mpulsweb/lib/translation.py
Log:
Implement fallback if a translation can not be found in custom i18n dir


Modified: base/trunk/mpulsweb/lib/translation.py
===================================================================
--- base/trunk/mpulsweb/lib/translation.py	2010-06-09 12:27:00 UTC (rev 2945)
+++ base/trunk/mpulsweb/lib/translation.py	2010-06-09 13:13:13 UTC (rev 2946)
@@ -3,6 +3,7 @@
 from gettext import NullTranslations, translation
 
 import pylons
+from pylons.i18n.translation import get_lang
 
 # Copied from pylons.i18n.translation. Adapted code to allow otional locations
 # of language files
@@ -18,8 +19,11 @@
         _('This should be in lots of languages')
     
     """
+    base_translated = _get_translator(get_lang())
     translated = pylons.translator.ugettext(value)
-    log.debug("String: %s" % translated)
+    if translated == value:
+        # Seems not to be translated look in baseapplication
+        translated = base_translated.ugettext(value)
     return translated
 
 _ = ugettext
@@ -39,10 +43,11 @@
         rootdir = conf['pylons.paths']['root']
     except KeyError:
         rootdir = conf['pylons.paths'].get('root_path')
-    if conf['pylons.paths'].has_key('i18n'):
-        localedir = conf['pylons.paths'].get('i18n')
-    else:
-        localedir = os.path.join(rootdir, 'i18n')
+    localedir = os.path.join(rootdir, 'i18n')
+    if 'i18n_dir' in kwargs:
+        dir = kwargs.pop('i18n_dir')
+        if dir is not None:
+            localedir = dir
     if not isinstance(lang, list):
         lang = [lang]
     try:



More information about the Mpuls-commits mailing list