[pygtk] gtk.Builder and translation directory

Osmo Salomaa otsaloma at cc.hut.fi
Sun Mar 8 11:47:21 WST 2009


ti, 2009-03-03 kello 23:20 +0100, Cezary Krzyżanowski kirjoitti:
> Actually I've got the same problem with gtk.Builder. All in-program  
> strings get translated superbliy, but gtk.Labels and other widgets  
> designed in glade-3 and converted to gtk.Builder xml don't. This is  
> both by using the set_translation_domain property and not doing it.

Turns out my minimal test case worked only because it was
using /usr/share/locale. Elsewhere translations with gtk.Builder fail,
while gettext.gettext and glade work fine. I filed a bug.

http://bugzilla.gnome.org/show_bug.cgi?id=574520

> The trick that works is doing something like this:
> 
> [...]
> 
> and using this patched Builder for all object creation. The PITA of  
> this is that now I have to epxplicitly use get_object on each and  
> every widget(label) I have defined in my GUI, even those, that I don't  
> actually change or modify in the code ever!

I did something very similar as a workaround. Instead of overriding
get_object, you can just loop through all the objects with get_objects()
during the __init__ call and translate the strings there. In addition to
gtk.Labels, I also do obj.set_title(_(obj.get_title())) to translate all
window titles.

-- 
Osmo Salomaa <otsaloma at cc.hut.fi>



More information about the pygtk mailing list