[Twisted-web] nevow/i18n.py - Suggested handling of missing domain,
 localedir or languages
    Paul Reznicek 
    maillists at ivsn.com
       
    Mon Jul 25 03:44:45 MDT 2005
    
    
  
Using        gettext.NullTranslations()
allow to     return translation.ugettext(s)
also when domain, localedir or language is missing, so the result
is always an Unicode object. (...and is less code ;-)
-Paul
===================================================================
--- i18n.py    (Revision 1672)
+++ i18n.py    (Arbeitskopie)
@@ -133,14 +135,9 @@
                  localedir=localeDir,
                  languages=languages,
                  )
-        except IOError, e:
-            if e.errno == errno.ENOENT:
-                # no locale file found
-                return s
-            else:
-                raise
-        else:
-            return translation.ugettext(s)
+        except IOError:
+            translation = gettext.NullTranslations()
+        return translation.ugettext(s)
      def __init__(self, **kw):
          """
    
    
More information about the Twisted-web
mailing list