[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: python's gettext.gettext broken, use gettext.lgettext



On Mon, 2005-08-08 at 07:45 +0900, Junichi Uekawa wrote:
> Hi,
> 
> While I was hacking at debconf, I noticed that 
> python's gettext function returns strings encoded in the 
> original encoding; which will appear as garbage on 
> the screen.

The best way to do gettext in Python is to do:

gettext.install(textdomain, unicode=True)

Which installs ugettext as '_' function into the __builtin__ namespace.
That makes _ return Python 'unicode' objects, which is what programs
should be using internally anyway.

This is harder if you're trying to localize a module since then you
don't want to screw with __builtin__; you should use a local _
assignment instead (http://www.python.org/doc/current/lib/node329.html).
It's basically what you wrote.
-- 
Joe Wreschnig <piman@debian.org>

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: