Wxwidgets' messages in Spanish

Monday, June 18, 2007

In a cpp wxwidgets app...

1 - Within the source wxwidgets , there's a samples folder.

2 - cd to samples folder , and then to calendar folder.

3 - Add this line before the end of the wxApp class in calendar.cpp...


wxLocale m_locale;

4 - Add these four at the beginning of the OnInit method of the inherited wxApp...

if( m_locale.Init()){
m_locale.AddCatalog(wxT("es"));
m_locale.AddCatalogLookupPathPrefix( wxT("."));

}

5 - Compile the sample with ... make -f makefile.unx ( this in MacOSX or any Unix)

6 - Do this if in MacOSX ...

$ mkdir calendar.app
$ cd calendar.app
$ mkdir Contents
$ cd Contents
$ mkdir MacOS
$ cd MacOS
$ ln -s ../../../calendar calendar
$ cd ../../..
$ open calendar.app

7 - If everything goes as expected days and months of the calendar widget get displayed in spanish.

In you want to apply this in a wxpython program...

1 - If you started your wxpython program with wx.PySimpleApp, ie ...
app = wx.PySimpleApp()

2 - add these lines after that ...

locale = wx.Locale()
if locale.Init(wx.LANGUAGE_DEFAULT , wx.LOCALE_LOAD_DEFAULT | wx.LOCALE_CONV_ENCODING ):
locale.AddCatalog("es")
locale.AddCatalogLookupPathPrefix(".")


3 - After this if your program , for example, uses wx.PreviewFrame, all messages in the frame and widgets will be displayed in Spanish!

0 comments: to “ Wxwidgets' messages in Spanish so far...