Encoding problems with gettext and wxPython: how to do things in "good style"

André andre.roberge at gmail.com
Wed Mar 1 20:09:44 EST 2006


I'm trying to change an app so that it uses gettext for translations
rather than the idiosyncratic way I am using.  I've tried the example
on the wxPython wiki
http://wiki.wxpython.org/index.cgi/RecipesI18n
but found that the accented letters would not display properly.  I have
found a workaround that works from Python in a Nutshell; however it is
said in that book that
   "...this is not good style".

I would like to do things "in good style" :-)

Here are some further details:
1. all the .po files are encoded in utf-8
2. my local sitecustomization uses iso-8859-1   (yes, I could easily
change it on *my* computer, but I want the solution to work for anyone
else, without asking them to change their local default encoding).
3. I am programming under Windows XP.

The workaround I use is to write the following at the beginning of the
script:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
del sys.setdefaultencoding
====
I tried various other ways to change the encoding in the example given,
but nothing else worked.

I can live with the "bad style" workaround if nothing else...

André


I have tried




More information about the Python-list mailing list