]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/internat/internat.cpp
Watcom does not accept #warning but supports more than MSW port.
[wxWidgets.git] / samples / internat / internat.cpp
index f84b7b3aa0115be64288943372ac19240647a049..dd1fe4bbd815df7d1b37ab51a56ba9899b4fca1f 100644 (file)
@@ -85,6 +85,53 @@ enum
     INTERNAT_OPEN
 };
 
+// language data
+static const wxLanguage langIds[] =
+{
+    wxLANGUAGE_DEFAULT,
+    wxLANGUAGE_FRENCH,
+    wxLANGUAGE_GERMAN,
+    wxLANGUAGE_RUSSIAN,
+    wxLANGUAGE_BULGARIAN,
+    wxLANGUAGE_CZECH,
+    wxLANGUAGE_POLISH,
+    wxLANGUAGE_SWEDISH,
+#if wxUSE_UNICODE || defined(__WXMOTIF__)
+    wxLANGUAGE_JAPANESE,
+#endif
+#if wxUSE_UNICODE
+    wxLANGUAGE_GEORGIAN,
+    wxLANGUAGE_ENGLISH,
+    wxLANGUAGE_ENGLISH_US
+#endif
+};
+
+// 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("Bulgarian"),
+    _T("Czech"),
+    _T("Polish"),
+    _T("Swedish"),
+#if wxUSE_UNICODE || defined(__WXMOTIF__)
+    _T("Japanese"),
+#endif
+#if wxUSE_UNICODE
+    _T("Georgian"),
+    _T("English"),
+    _T("English (U.S.)")
+#endif
+};
+
+// the arrays must be in sync
+wxCOMPILE_TIME_ASSERT( WXSIZEOF(langNames) == WXSIZEOF(langIds),
+                       LangArraysMismatch );
+
 // ----------------------------------------------------------------------------
 // wxWidgets macros
 // ----------------------------------------------------------------------------
@@ -121,48 +168,8 @@ bool MyApp::OnInit()
         tmp.ToLong(&lng);
     }
 
-    static const wxLanguage langIds[] =
-    {
-        wxLANGUAGE_DEFAULT,
-        wxLANGUAGE_FRENCH,
-        wxLANGUAGE_GERMAN,
-        wxLANGUAGE_RUSSIAN,
-        wxLANGUAGE_BULGARIAN,
-        wxLANGUAGE_CZECH,
-        wxLANGUAGE_POLISH,
-#if wxUSE_UNICODE
-        wxLANGUAGE_JAPANESE,
-        wxLANGUAGE_GEORGIAN,
-#endif
-        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("Bulgarian"),
-            _T("Czech"),
-            _T("Polish"),
-#if wxUSE_UNICODE
-            _T("Japanese"),
-            _T("Georgian"),
-#endif
-            _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:"),
@@ -173,7 +180,15 @@ bool MyApp::OnInit()
     }
 
     if ( lng != -1 )
-        m_locale.Init(langIds[lng]);
+    {
+        // 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(langIds[lng], wxLOCALE_CONV_ENCODING) )
+        {
+            wxLogError(_T("This language is not supported by the system."));
+            return false;
+        }
+    }
 
     // normally this wouldn't be necessary as the catalog files would be found
     // in the default locations, but under Windows then the program is not
@@ -354,7 +369,7 @@ void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
         for (int n = first; n <= last; ++n)
         {
             s << n << _T(" ") <<
-                wxGetTranslation(_T("file deleted"), _T("files deleted"), n) <<
+                wxPLURAL("file deleted", "files deleted", n) <<
                 _T("\n");
         }
         wxMessageBox(s);