13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Internationalizationhttp://www.zetcode.com/wxpython/in18/mylocale.AddCatalog('simple_de')_ = wx.GetTranslationwx.StaticText(panel, -1, _("hello"), (10, 10))#wx.StaticText(panel, -1, wx.GetTranslation('hello'), (10, 10))self.Centre()self.Show(True)app = wx.App()Translation(None, -1, 'Translation')app.MainLoop()Next we create a so called PO file. It is a simple text file, whichis translators use to translate the strings.pygettext -o simple_de.po simple.pyTo create a po file, we use the pygettext command. To fullyunderstand the format of the po file, consult the gnu gettextmanual."Content-Type: text/plain; charset=utf-8\n"We edit the simple_de.po file. We must specify the charset. Inour case it is utf-8.#: simple.py:17msgid "hello"msgstr "Grüß Gott"Here we provide a translation for the hello string.<strong>The</strong> last thing we do is to create a binary message catalog.msgfmt --output-file simple_de.mo simple_de.poTo produce a mo file, we call the msgfmt command.11 de 12 27/04/2008 1:06

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!