[Python-Dev] Re: gettext in the standard library

M.-A. Lemburg mal@lemburg.com
Sat, 19 Aug 2000 11:44:19 +0200


James Henstridge wrote:
> 
> On Fri, 18 Aug 2000, Barry A. Warsaw wrote:
> 
> > I started with Martin's libintlmodule, renamed it _gettext and cleaned
> > up the C code a bit.  This provides gettext(), dgettext(),
> > dcgettext(), textdomain(), and bindtextdomain() functions.  The
> > gettext.py module imports these, and if it succeeds, it's done.
> >
> > If that fails, then there's a bunch of code, mostly derived from
> > Peter's fintl.py module, that reads the binary .mo files and does the
> > look ups itself.  Note that Peter's module only supported the GNU
> > gettext binary format, and that's all mine does too.  It should be
> > easy to support other binary formats (Solaris?) by overriding one
> > method in one class, and contributions are welcome.
> 
> I think support for Solaris big endian format .po files would probably be
> a good idea.  It is not very difficult and doesn't really add to the
> complexity.
> 
> >
> > James's stuff looked cool too, what I grokked of it :) but I think
> > those should be exported as higher level features.  I didn't include
> > the ability to write .mo files or the exported Catalog objects.  I
> > haven't used the I18N services enough to know whether these are
> > useful.
> 
> As I said above, most of that turned out not to be very useful.  Did you
> include any of the language selection code in the last version of my
> gettext module?  It gave behaviour very close to C gettext in this
> respect.  It expands the locale name given by the user using the
> locale.alias files found on the systems, then decomposes that into the
> simpler forms.  For instance, if LANG=en_GB, then my gettext module would
> search for catalogs by names:
>   ['en_GB.ISO8859-1', 'en_GB', 'en.ISO8859-1', 'en', 'C']
> 
> This also allows things like expanding LANG=catalan to:
>   ['ca_ES.ISO-8859-1', 'ca_ES', 'ca.ISO-8859-1', 'ca', 'C']
> (provided the appropriate locale.alias files are found)
> 
> If you missed that that version I sent you I can send it again.  It
> stripped out a lot of the experimental code giving a much simpler module.

Uhm, can't you make some use of the new APIs in locale.py
for this ?

locale.py has a whole new set of encoding aware support for
LANG variables. It supports Unix and Windows (thanks to /F).
 
--
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/