[Twisted-web] nevow/i18n.py - Suggested handling of missing domain, localedir or languages

Tommi Virtanen tv at twistedmatrix.com
Mon Jul 25 23:25:51 MDT 2005


Paul Reznicek wrote:

> 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):
>          """


Don't take away the

            if e.errno == errno.ENOENT:




More information about the Twisted-web mailing list