Patch #834 2006-02-15 08:14

heromyth

For more convenience of using the internationlized CB
Download
834-For_more_conven.patch (9.7 KB)
Category
Application::FeatureAdd
Status
Accepted
Close date
2006-02-15 08:45
Assigned to
 
Index: D:/codeblocks/src/src/app.cpp
===================================================================
--- D:/codeblocks/src/src/app.cpp    (revision 2006)
+++ D:/codeblocks/src/src/app.cpp    (working copy)
@@ -276,55 +276,26 @@
 void CodeBlocksApp::InitLocale()
 {
     ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("app"));
-    const wxString langs[] =
-    {
-        _T("(System default)")
-//        ,_T("English (U.S.)")
-//        ,_T("English")
-//        ,_T("Chinese (Simplified)")
-//        ,_T("German")
-//        ,_T("Russian")
-    };
 
-    // Must have the same order than the above
-    const long int locales[] =
-    {
-        wxLANGUAGE_DEFAULT
-//        ,wxLANGUAGE_ENGLISH_US
-//        ,wxLANGUAGE_ENGLISH
-//        ,wxLANGUAGE_CHINESE_SIMPLIFIED
-//        ,wxLANGUAGE_GERMAN
-//        ,wxLANGUAGE_RUSSIAN
-    };
 
-    long int lng = cfg->ReadInt(_T("/locale/language"),(long int)-2);
+    bool i18n=cfg->ReadBool(_T("/environment/I18N"),LOCALIZE);
+    int lng =-1;    // -1 = Don't use locale; the default is 0 = Use locale
+    if(i18n)
+        lng = cfg->ReadInt(_T("/locale/language"),(int)0);
 
-    if (lng <= -2 && WXSIZEOF(langs)>=2) // ask only if undefined and there are at least 2 choices
-    {
-        lng = wxGetSingleChoiceIndex(_T("Please choose language:"), _T("Language"), WXSIZEOF(langs), langs);
-        if (lng >= 0 && static_cast<unsigned int>(lng) < WXSIZEOF(locales))
-        {
-            lng = locales[lng];
-        }
-    }
-    else
-    {
-        lng = -1; // -1 = Don't use locale
-    }
+    int catalogNum = cfg->ReadInt(_T("/locale/catalogNum"), (int)0);
+    if (catalogNum == 0)
+    {
+        catalogNum = 1;
+        cfg->Write(_T("/locale/Domain1"), "codeblocks");
+    }
 
     if (lng>=0)
     {
-        m_locale.Init(lng);
+        m_locale.Init(locales[lng]);
         wxLocale::AddCatalogLookupPathPrefix(ConfigManager::GetDataFolder() + _T("/locale"));
         wxLocale::AddCatalogLookupPathPrefix(wxT("."));
         wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
-        int catalogNum = cfg->ReadInt(_T("/locale/catalogNum"), (int)0);
-        if (catalogNum == 0)
-        {
-            catalogNum = 1;
-            cfg->Write(_T("/locale/Domain1"), "codeblocks");
-        }
-
         for (int i = 1; i <= catalogNum; ++i)
         {
             wxString tempStr = wxString::Format(_T("/locale/Domain%d"), i);
@@ -338,9 +309,10 @@
             else if (cfg->Read(_T("/plugins/") + catalogName))
                 m_locale.AddCatalog(catalogName);
         }
-        cfg->Write(_T("/locale/catalogNum"), (int)catalogNum);
+        
     }
-
+    cfg->Write(_T("/locale/catalogNum"), (int)catalogNum);
+    cfg->Write(_T("/environment/I18N"),  (bool)i18n);
     cfg->Write(_T("/locale/language"), (int)lng);
 }
 
Index: D:/codeblocks/src/src/appglobals.cpp
===================================================================
--- D:/codeblocks/src/src/appglobals.cpp    (revision 2006)
+++ D:/codeblocks/src/src/appglobals.cpp    (working copy)
@@ -43,3 +43,25 @@
 const wxString g_AppBuildTimestamp = (wxString(wxT(__DATE__)) + wxT(", ") + wxT(__TIME__) + wxT(" - wx") + wxString(wxT(wxVERSION_NUM_DOT_STRING)) + wxT(" (") + g_AppPlatform + wxT(", ") + g_AppWXAnsiUnicode + wxT(")") );
 
 const wxString g_DefaultBatchBuildArgs = _T("-na -nd -ns --batch-build-notify");
+
+
+const wxString langs[] =
+{
+    _("(System default)")
+//        ,_T("English (U.S.)")
+//        ,_T("English")
+    ,_("Chinese (Simplified)")
+//        ,_T("German")
+//        ,_T("Russian")
+};
+
+// Must have the same order than the above
+const int locales[] =
+{
+    wxLANGUAGE_DEFAULT
+//        ,wxLANGUAGE_ENGLISH_US
+//        ,wxLANGUAGE_ENGLISH
+    ,wxLANGUAGE_CHINESE_SIMPLIFIED
+//        ,wxLANGUAGE_GERMAN
+//        ,wxLANGUAGE_RUSSIAN
+};
Index: D:/codeblocks/src/src/appglobals.h
===================================================================
--- D:/codeblocks/src/src/appglobals.h    (revision 2006)
+++ D:/codeblocks/src/src/appglobals.h    (working copy)
@@ -16,4 +16,10 @@
 
 extern const wxString g_DefaultBatchBuildArgs;
 
+#define LOCALIZE   true
+#define LANGUAGES  2
+//Please fix this. I have no Idea that the WXSIZEOF couldn't work whithout defining LANGUAGES
+extern const wxString langs[LANGUAGES];
+extern const int locales[LANGUAGES];
+
 #endif // APPGLOBALS_H
Index: D:/codeblocks/src/src/environmentsettingsdlg.cpp
===================================================================
--- D:/codeblocks/src/src/environmentsettingsdlg.cpp    (revision 2006)
+++ D:/codeblocks/src/src/environmentsettingsdlg.cpp    (working copy)
@@ -66,6 +66,7 @@
     EVT_BUTTON(XRCID("btnAuiInactiveCaptionTextColor"), EnvironmentSettingsDlg::OnChooseColor)
     EVT_CHECKBOX(XRCID("chkDoPlace"), EnvironmentSettingsDlg::OnPlaceCheck)
     EVT_CHECKBOX(XRCID("chkPlaceHead"), EnvironmentSettingsDlg::OnHeadCheck)
+    EVT_CHECKBOX(XRCID("chkI18N"), EnvironmentSettingsDlg::OnI18NCheck)
download for full patch...