On 28/07/2003 8:48 PM, Alexandr V. Demeshko wrote:

First of all sorry for my poor English.

Could someone explain me how PyGtk, libglade and gettext should
work together?

When I call from Python glade.XML("mygladefile", domain="mydomain")
wrapper code does not use domain, instead passes it into libglade2 by
calling glade_xml_new. And then libglade2 uses "mydomain" internally.
But, AFAIU gtk requires that all strings are in UTF-8 encoding.
Therefore libglade2 should contain call to
bind_textdomain_codeset(domain, "UTF-8"). But it does not. And, of
course, strings are extracted not in UTF-8 but in system encoding and I
have error messages like "Bad UTF-8 string". There is no problem when I
use libglade from C - I just put call to bind_textdomain_codeset in my
own code. But Python AFAIK does not use libgettext. Instead it works
with .mo files directly. So I can't invoke bind_textdomain_codeset from
Python.

I've solved this problem for me by patching libglade2 - I've just added
call to bind_textdomain_codeset and all works OK. But I'm not sure that this is right solution. Why such call is absent even in fresh version of libglade2 - 2.0.1 ? I don't believe that nobody use such tool
combination before me. Maybe I misunderstand something?


So please help me. Thanks in advance.


Does calling gtk.glade.bindtextdomain("mydomain", "/path/to/locale/dir") help? This should set up the translation domain with the C level gettext library that libglade uses. It will also set the translation domain to return UTF-8 strings like GTK needs. This function is provided by the library for the benefit of pygtk programmers, since the functionality needed isn't exposed in the gettext or locale modules in Python 2.2.

The reason libglade doesn't call bind_textdomain_codeset() itself is that this would be unexpected behaviour. In many applications, some of the GUI is done with libglade and other bits are constructed manually. Usually the same message catalog will hold strings for both these parts of the GUI. A call to bind_textdomain_codeset() will change a global setting for that message catalog, which will change both uses of the gettext() function call. By making the user set up the catalog, the programmer will have to think about how they want to setup the catalog (the same way they have to call bindtextdomain() to bind the translation domain to catalogs in a particular directory).

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to