FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 22.3 | Next Entry >>

22.3. Why doesn't gettext work on my libglade UIs with Python <= 2.2?

Note: this has been fixed in Python2.3 by Martin v. Löwis; see the bug report at [sourceforge.net] for details.

This was actually a problem with Python. Python2.0 to 2.2 included a pure-python gettext.py module, which provides the same basic gettext API, but has some new features. The problem with a pure python implementation is that it never calls glibc textdomain() and bindtextdomain(). Since libglade is implemented in C, the internationalization happens outside the scope of the python interpreter. Without *textdomain(), libglade never knows that C gettext support is to be activated for the UI you are instantiating.

There are a few workarounds:

 gtk.glade.bindtextdomain(APP, DIR)
 gtk.glade.textdomain(APP)

 import dl
 l = dl.open('/lib/libc.so.6')
 l.call('bindtextdomain', APP, DIR)
 # if you want unicode strings:
 l.call('bind_textdomain_codeset', APP, 'UTF-8');

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org