I have reported it at
http://sourceforge.net/tracker/index.php?func=detail&aid=1428349&group_id=126998&atid=707416In src\app.cpp, I have changed the code of the function InitLocale() to this:
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);
//wxMessageBox(wxString::Format(" %d ",(int)lng));
if (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
// }
if (lng>=0)
{
m_locale.Init(lng);
wxLocale::AddCatalogLookupPathPrefix(ConfigManager::GetDataFolder() + _T("/locale"));
wxLocale::AddCatalogLookupPathPrefix(wxT("."));
wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
int catalogNum = cfg->ReadInt(_T("/locale/catalogNum"), 0);
wxMessageBox(wxString(_T("catalogNum==>")+wxString::Format(_T("%d"),catalogNum)));
if (catalogNum == 0)
{
catalogNum = 1;
cfg->Write(_T("/locale/Domain1"), _T("codeblocks"));
wxMessageBox(wxString(_T("OK")));
}
for (int i = 1; i <= catalogNum; ++i)
{
wxString tempStr = wxString::Format(_T("/locale/Domain%d"), i);
wxString catalogName = cfg->Read(tempStr, wxEmptyString);
wxMessageBox(_T("V")+tempStr+_T("V")+catalogName+_T("V"));
if (catalogName.IsEmpty())
{
cfg->Write(tempStr,
cfg->Read(wxString::Format(_T("/locale/Domain%d"), catalogNum)));
catalogNum--;
wxMessageBox(tempStr+wxString::Format(_T("/locale/Domain%d"), i));
}
else if (cfg->Read(_T("/plugins/") + catalogName))
{
m_locale.AddCatalog(catalogName);
wxMessageBox(tempStr+_T("==>")+catalogName);
}
}
cfg->Write(_T("/locale/catalogNum"), (int)catalogNum);
}
cfg->Write(_T("/locale/language"), (int)lng);
}
I don't think I have changed so many things. I just added some functions of wxMessageBox. Compiling it with ANSI and running seems no problem. However, it can't work correctly with UNICODE.
Before running, I deleted the configure file of default.conf. When running, it shows as belown:
with UNICODEcatalogNum==>0
OK
V/locale/Domain1VV
/locale/Domain1/locale/Domain1
......
with ANSIcatalogNum==>0
OK
V/locale/Domain1VcodeblocksV
/locale/Domain1==>codeblocks
......
With UNICODE and no the file of default.conf, the cfg->Read and cfg->Write seems can't work correctly. I have tested that the two functions work correctly if the file of default.conf exists. Although the file doesn't exist, yet the two functions work correctly with ANSI.
Although whithout my moditation to the function InitLocale(), you can compare the two files of default.conf genternated by CB with UNICODE and with ANSI. Notice the value of /locale/Domain1.
Because of this problem, I can't finish the i18n of CB with UNICODE. Now, I can easily finish the i18n because having found the reason. I have try to solve it but failed.