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

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


Martin von Loewis wrote:
> 
> In any case, I think it is a good idea to support retrieval of
> translated strings as Unicode objects. I can think of two alternative
> interfaces:
> 
> gettext.gettext(msgid, unicode=1)
> #or
> gettext.unigettext(msgid)
> 
> Of course, if applications install _, they'd know whether they want
> unicode or byte strings, so _ would still take a single argument.

Hmm, if your catalogs are encoded in UTF-8 and use non-ASCII
chars then the traditional API would have to raise encoding
errors -- probably not a good idea since the errors would be
hard to deal with in large applications.

Perhaps the return value type of .gettext() should be given on
the .install() call: e.g. encoding='utf-8' would have .gettext()
return a string using UTF-8 while encoding='unicode' would have
it return Unicode objects.
 
[Which makes me think: perhaps I should add a new codec which
does pretty much the same as the unicode() call: convert the
input data to Unicode ?!]

> However, I don't think that this feature must be there at the first
> checkin; I'd volunteer to work on a patch after Barry has installed
> his code, and after I got some indication what the interface should
> be.

Right.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/