On 27/04/2011 21:56, Gerald Britton wrote: > Does anyone know if a tooltip string, generated from glade file, is of > type string or unicode. > > I think that the string must be unicode when calling gettext and the > string contains non ascii > characters.
Just to be sure we're not going to get confused there's an important little fact to deal with here: GTK+ requires us to call bind_textdomain_codeset(domain, 'UTF-8'). See the second paragraph in section 1.7 of [1]. With that taken care of: Depends on how you want to access said string: - gtk.Widget.get_tooltip_(text|markup) returns an utf-8 encoded str. - Python's gettext.ugettext() always returns a unicode - Python's gettext.gettext() always returns an encoded 8-bit str -> This is explained in the second paragraph of [2]. The case of gettext.gettext() is going to be utf-8 encoded due to the bind_textdomain_codeset() call explained above. I've poured everything I've learned about gettext/libintl and how it interacts with GTK+ into a reusable module availeble at [3]. It also contains some code to get translated strings from GtkBuilder/libglade files working on Windows. Maybe it can be of some use... > At least it is so for tooltips generated in python code. That's surprising. I've always worked with plain (utf-8 encoded) strings. Then again all my Python source files have # -*- coding: utf-8 -*- at the beginning of the file and gettext/libintl are always initialized with bind_textdomain_codeset(domain, 'UTF-8'). mvg, Dieter [1] http://developer.gnome.org/gtk/2.24/gtk-question-index.html [2] http://docs.python.org/library/gettext.html#the-gnutranslations-class [3] https://github.com/dieterv/elib.intl/blob/master/lib/elib/intl/__init__.py _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/