| FAQ Index - Search - Recent Changes - Everything - Add 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:
- One is to use Martin's C gettext module intl.so, which can be downloaded from [www.informatik.hu-berlin.de] If you import intl and call the *textdomain() functions, things should work fine.
- You may try upgrading to Python 2.2.2 - its "locale" module now has the required functions. [This is currently not much tested - reports are welcome.]
- If you are using a not too old PyGTK version, it contains gtk.glade.bindtextdomain() and gtk.glade.textdomain(), so this will do:
gtk.glade.bindtextdomain(APP, DIR) gtk.glade.textdomain(APP)
- Last - and perhaps least - a dirty trick if your Python installation contains the "dl" module:
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');
