1 // Example for use of GNU gettext.
2 // This file is in the public domain.
4 // Source code of the C++ program.
9 /* Get getpid() declaration. */
14 class MyApp
: public wxApp
17 virtual bool OnInit();
19 // wxWidgets has the concept of a "current locale". It is the one returned
20 // by wxGetLocale() and implicitly used by wxGetTranslation.
21 // But there is no way to explicitly set this current locale! Rather, it is
22 // always set to the last constructed locale(!), and is modified when a
23 // locale is destroyed. In such a way that the current locale points to
24 // invalid memory after you do
25 // wxLocale *a = new wxLocale;
26 // wxLocale *b = new wxLocale;
29 // So, to avoid problems, we use exactly one instance of wxLocale, and keep
30 // it alive for the entire application lifetime.
34 class MyFrame
: public wxFrame
40 // This defines the main() function.
45 // First, register the base directory where to look up .mo files.
46 wxLocale::AddCatalogLookupPathPrefix(wxT(LOCALEDIR
));
47 // Second, initialize the locale and set the application-wide message domain.
49 appLocale
.AddCatalog(wxT("hello-c++-wxwidgets"));
50 // Now wxGetLocale() is initialized appropriately.
52 // Then only start building the GUI elements of the application.
54 // Create the main frame window.
55 MyFrame
*frame
= new MyFrame();
65 : wxFrame(NULL
, wxID_ANY
, _T("Hello example"))
67 wxStaticText
*label1
=
68 new wxStaticText(this, wxID_ANY
, _("Hello, world!"));
71 wxString::Format(_("This program is running as process number %d."),
73 wxStaticText
*label2
=
74 new wxStaticText(this, wxID_ANY
, label2text
);
76 wxBoxSizer
*topSizer
= new wxBoxSizer(wxVERTICAL
);
77 topSizer
->Add(label1
);
78 topSizer
->Add(label2
);