[pygtk] i18n and Glade
Mystilleef
mystilleef at gmail.com
Mon Mar 12 08:20:08 WST 2007
On 3/11/07, Justin Mazzola Paluska <jmp at mit.edu> wrote:
> On Sat, Mar 10, 2007 at 11:47:05PM +0000, Mystilleef wrote:
> > Hello,
> >
> > The glade generated GUIs in my project are not being localized. I have
> > tried initializing the python glade gettext functions but to no avail.
> > My i18n initialization function looks like this.
> >
> > ------------------------------------------------------------------------
> >
> > from gettext import bindtextdomain, textdomain
> > from gettext import bind_textdomain_codeset, install
> > from locale import setlocale, LC_ALL, Error
> > bindtextdomain(appname, locale_folder)
> > textdomain(appname)
> > bind_textdomain_codeset(appname, "UTF-8")
> > install(appname, locale_folder, unicode=1)
> > try:
> > setlocale(LC_ALL, "")
> > except Error:
> > pass
> > ####Glade Stuff.
> > from gtk.glade import bindtextdomain, textdomain
> > bindtextdomain(appname, locale_folder)
> > textdomain(appname)
>
> Have you tried putting the glade internationalization before the
> python one? Or putting the locale before all of the binding? I've
> also never used gettext.install. The following seems to work in my
> application:
>
> import locale
> import gettext
> import gtk
> import gtk.glde
>
> locale.setlocale(locale.LC_ALL, '')
> # see http://bugzilla.gnome.org/show_bug.cgi?id=344926 for why the
> # next two commands look repeated.
> gtk.glade.bindtextdomain(GETTEXT_DOMAIN,
> LOCALE_PATH)
> gtk.glade.textdomain(GETTEXT_DOMAIN)
> gettext.bindtextdomain(GETTEXT_DOMAIN,
> LOCALE_PATH)
> gettext.textdomain(GETTEXT_DOMAIN)
>
> > i18n works fine for none-glade GUIs. My only problem is with glade
> > generated GUIs. Do I need to do anything special to get internalization
> > for glade generated GUIs? Anyone having this problem?
>
> This is a silly question, but you did extract the strings from your
> GUI to a po file, right?
> —Justin
>
Thanks a lot for the pointers. Unfortunately, I'm still having the problem.
More information about the pygtk
mailing list