- // set the language to use
- const char *language = NULL;
- const char *langid = NULL;
- switch ( argc )
- {
- default:
- // ignore the other args, fall through
-
- case 3:
- language = argv[1];
- langid = argv[2];
- break;
-
- case 2:
- language = argv[1];
- break;
-
- case 1:
- language = "french";
- langid = "fr";
- };
-
- // there are very few systems right now which support locales other than "C"
- m_locale.Init(language, langid, "C");
-
- // Initialize the catalogs we'll be using
- /* 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, 250, 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;
+ long lng = -1;
+
+ if ( argc == 2 )
+ {
+ // the parameter must be the lang index
+ wxString tmp(argv[1]);
+ tmp.ToLong(&lng);
+ }
+
+ static const wxLanguage langIds[] =
+ {
+ wxLANGUAGE_DEFAULT,
+ wxLANGUAGE_FRENCH,
+ wxLANGUAGE_GERMAN,
+ wxLANGUAGE_RUSSIAN,
+ wxLANGUAGE_JAPANESE,
+ wxLANGUAGE_ENGLISH,
+ wxLANGUAGE_ENGLISH_US,
+ };
+
+ if ( lng == -1 )
+ {
+ // note that it makes no sense to translate these strings, they are
+ // shown before we set the locale anyhow
+ const wxString langNames[] =
+ {
+ _T("System default"),
+ _T("French"),
+ _T("German"),
+ _T("Russian"),
+ _T("Japanese"),
+ _T("English"),
+ _T("English (U.S.)")
+ };
+
+ // the arrays should be in sync
+ wxCOMPILE_TIME_ASSERT( WXSIZEOF(langNames) == WXSIZEOF(langIds),
+ LangArraysMismatch );
+
+ lng = wxGetSingleChoiceIndex
+ (
+ _T("Please choose language:"),
+ _T("Language"),
+ WXSIZEOF(langNames),
+ langNames
+ );
+ }
+
+ if ( lng != -1 )
+ m_locale.Init(langIds[lng]);
+
+
+ // 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(wxID_ABOUT, _("&About..."));
+ file_menu->AppendSeparator();
+ file_menu->Append(INTERNAT_QUIT, _("E&xit"));
+
+ wxMenu *test_menu = new wxMenu;
+ test_menu->Append(INTERNAT_OPEN, _("&Open bogus file"));
+ test_menu->Append(INTERNAT_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;