[pygtk] Using gettext, where am I doing mistake

Vláďa vladovi at atlas.cz
Tue Apr 29 03:17:35 WST 2008


Hello,

I'm trying to translate my own application written in PyGTK on Windows. =

This is what I did:

First of all my test application *translate.py* stored in c:\Python:

#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import gettext
import locale

gettext.install('translate','locale')
locale.setlocale(locale.LC_ALL, '')
print locale.getdefaultlocale()

class HelloWorld:

    def destroy(self, widget, data=3DNone):
        gtk.main_quit()

    def __init__(self):
        self.window =3D gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(10)
        self.button =3D gtk.Button(_("Hello world"))
        self.button.connect("clicked", self.destroy, None)
        self.window.add(self.button)
        self.window.show_all()

    def main(self):
        gtk.main()

if __name__ =3D=3D "__main__":
    translate =3D HelloWorld()
    translate.main()

I installed gettext for Windows and according to =

/http://faq.pygtk.org/index.py?req=3Dshow&file=3Dfaq22.002.htp/ did next st=
eps:
1) Extract strings to a .pot file using xgettext
2) Create  cs.po file using msginit
3) Translated the cs.po file with PSPad.
4) Compile the cs.po file to cs.mo using msgfmt
5) Copy the cs.mo to /c:\Python\locale\cs_CZ\LC_MESSAGES\translate.mo/

Now I expected my test application to start with the Czech translation I =

made. But it still shows the original "Hello World" string.  The =

function locale.getdefaultlocale()[0] returns "cs_CZ" so I do believe my =

language is set correctly.

Do you have any ideas what am I doing wrong?

Many thanks and best regards,
Vlada
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20080428/fc2f8608/at=
tachment.htm


More information about the pygtk mailing list