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/message catalogs. Each translation has one catalog. Say, wewant to translate a string into german language. First, we mustensure, that we have language support for german language.$ locale -aCde_AT.utf8de_BE.utf8de_CH.utf8de_DE.utf8de_LU.utf8en_AU.utf8en_BW.utf8en_CA.utf8en_DK.utf8en_GB.utf8en_HK.utf8en_IE.utf8en_INen_NZ.utf8en_PH.utf8en_SG.utf8en_US.utf8en_ZA.utf8en_ZW.utf8POSIXsk_SK.utf8To check what languages are supported, we use the localecommand. On my system, I have english, german and slovaklanguage support. English language and german language havedifferent dialects, that's why we have so many options. Noticethe utf8 string. This means, that the system uses utf8 encodingfor working with strings.Next we write our code example. We put the string that are tobe translated into this _(), or we can use thewx.GetTranslation() call.#!/usr/bin/pythonimport wxclass Translation(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(220, 100))panel = wx.Panel(self, -1)mylocale = wx.Locale()mylocale.AddCatalogLookupPathPrefix('.')10 de 12 27/04/2008 1:06

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

Saved successfully!

Ooh no, something went wrong!