-bool MyApp::OnInit(void)
-{
- // Initialize the catalogs we'll be using
- m_locale.Init("french", "fr", "C");
-
- /* not needed any more, done in wxLocale ctor
- m_locale.AddCatalog("wxstd"); // 1) for library messages
- */
- m_locale.AddCatalog("internat"); // 2) our private one
- /* this catalog is installed in standard location on Linux systems,
- it might not be installed on yours - just ignore the errrors
- or comment out this line then */
- m_locale.AddCatalog("fileutils"); // 3) and another just for testing
-
- // Create the main frame window
- MyFrame *frame = new MyFrame((wxFrame *) NULL, _("International wxWindows App"), 50, 50, 150, 40);
-
- // Give it an icon
- frame->SetIcon(wxICON(mondrian));
-
- // Make a menubar
- wxMenu *file_menu = new wxMenu;
- file_menu->Append(MINIMAL_ABOUT, _("&About"));
- file_menu->AppendSeparator();
- file_menu->Append(MINIMAL_QUIT, _("E&xit"));
-
- wxMenu *test_menu = new wxMenu;
- test_menu->Append(MINIMAL_OPEN, _("&Open bogus file"));
- test_menu->Append(MINIMAL_TEST, _("&Play a game"));
-
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, _("&File"));
- menu_bar->Append(test_menu, _("&Test"));
- frame->SetMenuBar(menu_bar);
-
- // Show the frame
- frame->Show(TRUE);
- SetTopWindow(frame);
-
- return TRUE;
+bool MyApp::OnInit()
+{
+ if ( !wxApp::OnInit() )
+ return false;
+
+ if ( m_lang == wxLANGUAGE_UNKNOWN )
+ {
+ int lng = wxGetSingleChoiceIndex
+ (
+ _("Please choose language:"),
+ _("Language"),
+ WXSIZEOF(langNames),
+ langNames
+ );
+ m_lang = lng == -1 ? wxLANGUAGE_DEFAULT : langIds[lng];
+ }
+
+ if ( m_lang != wxLANGUAGE_DEFAULT )
+ {
+ // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
+ // false just because it failed to load wxstd catalog
+ if ( !m_locale.Init(m_lang, wxLOCALE_CONV_ENCODING) )
+ {
+ wxLogWarning(_("This language is not supported by the system."));
+
+ // continue nevertheless
+ }
+ }
+
+ // normally this wouldn't be necessary as the catalog files would be found
+ // in the default locations, but when the program is not installed the
+ // catalogs are in the build directory where we wouldn't find them by
+ // default
+ wxLocale::AddCatalogLookupPathPrefix(wxT("."));
+
+ // Initialize the catalogs we'll be using
+ m_locale.AddCatalog(wxT("internat"));
+
+ // this catalog is installed in standard location on Linux systems and
+ // shows that you may make use of the standard message catalogs as well
+ //
+ // if it's not installed on your system, it is just silently ignored
+#ifdef __LINUX__
+ {
+ wxLogNull noLog;
+ m_locale.AddCatalog(_T("fileutils"));
+ }
+#endif
+
+ // Create the main frame window
+ MyFrame *frame = new MyFrame(m_locale);
+
+ // Give it an icon
+ frame->SetIcon(wxICON(mondrian));
+
+ // Make a menubar
+ wxMenu *file_menu = new wxMenu;
+ file_menu->Append(INTERNAT_TEST, _("&Test locale availability...\tCtrl-T"));
+ file_menu->AppendSeparator();
+ file_menu->Append(wxID_ABOUT, _("&About..."));
+ file_menu->AppendSeparator();
+ file_menu->Append(wxID_EXIT, _("E&xit"));
+
+ wxMenu *test_menu = new wxMenu;
+ test_menu->Append(wxID_OPEN, _("&Open bogus file"));
+ test_menu->Append(INTERNAT_PLAY, _("&Play a game"));
+ test_menu->AppendSeparator();
+ test_menu->Append(INTERNAT_TEST_1, _("&1 _() (gettext)"));
+ test_menu->Append(INTERNAT_TEST_2, _("&2 _N() (ngettext)"));
+ test_menu->Append(INTERNAT_TEST_3, _("&3 wxTRANSLATE() (gettext_noop)"));
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, _("&File"));
+ menu_bar->Append(test_menu, _("&Test"));
+ frame->SetMenuBar(menu_bar);
+
+ // Show the frame
+ frame->Show(true);
+ SetTopWindow(frame);
+
+ return true;