From: Mapi B. <ma...@us...> - 2009-10-21 20:55:03
|
Update of /cvsroot/easycalc/PPCport/compat In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27506 Modified Files: Lang.cpp Lang.h Log Message: Bug fixes, dynamic language change enabled on UI. Index: Lang.h =================================================================== RCS file: /cvsroot/easycalc/PPCport/compat/Lang.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Lang.h 17 Oct 2009 13:44:17 -0000 1.2 --- Lang.h 21 Oct 2009 20:54:50 -0000 1.3 *************** *** 34,37 **** --- 34,38 ---- stdext::hash_map<String,String> translation; public: + int systLangId; String langName; TCHAR *localeInfo; *************** *** 56,60 **** Lang *defLang; TCHAR *wcstr; ! size_t allocLen; stdext::hash_map<String,Lang*> libLang; stdext::hash_map<String,Lang*>::const_iterator libIterator; --- 57,61 ---- Lang *defLang; TCHAR *wcstr; ! size_t allocLen; // Track size m-allocated to wcstr stdext::hash_map<String,Lang*> libLang; stdext::hash_map<String,Lang*>::const_iterator libIterator; *************** *** 70,74 **** --- 71,77 ---- const TCHAR *getNext(void); int setLang(TCHAR *langName); + const TCHAR *getLang(int systLangId); const TCHAR *getLang(void); + const TCHAR *getLangByIndex(int index); const TCHAR *translate(TCHAR *key); }; Index: Lang.cpp =================================================================== RCS file: /cvsroot/easycalc/PPCport/compat/Lang.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Lang.cpp 17 Oct 2009 13:44:17 -0000 1.2 --- Lang.cpp 21 Oct 2009 20:54:49 -0000 1.3 *************** *** 65,83 **** --- 65,89 ---- if (_tcscmp(name, _T("cs")) == 0) { codePage = 1250; + systLangId = MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT); localeInfo = _tsetlocale(LC_ALL, _T("Czech")); } else if (_tcscmp(name, _T("de")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN); localeInfo = _tsetlocale(LC_ALL, _T("German")); } else if (_tcscmp(name, _T("en")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); localeInfo = _tsetlocale(LC_ALL, _T("English")); } else if (_tcscmp(name, _T("fr")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH); localeInfo = _tsetlocale(LC_ALL, _T("French")); } else if (_tcscmp(name, _T("it")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_ITALIAN, SUBLANG_ITALIAN); localeInfo = _tsetlocale(LC_ALL, _T("Italian")); } else if (_tcscmp(name, _T("ja")) == 0) { codePage = 932; + systLangId = MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT); localeInfo = _tsetlocale(LC_ALL, _T("Japanese_Japan.932")); // This may not load correctly on western systems with Japan non installed, *************** *** 88,101 **** --- 94,111 ---- } else if (_tcscmp(name, _T("pt")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_PORTUGUESE, SUBLANG_PORTUGUESE); localeInfo = _tsetlocale(LC_ALL, _T("Portuguese")); } else if (_tcscmp(name, _T("ru_koi8")) == 0) { // Note that koi8-u, for Ukrainia, is 21866 codePage = 20866; + systLangId = MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT); localeInfo = _tsetlocale(LC_ALL, _T("Russian_Russia.20866")); } else if (_tcscmp(name, _T("ru_win")) == 0) { codePage = 1251; + systLangId = MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT); localeInfo = _tsetlocale(LC_ALL, _T("Russian")); } else if (_tcscmp(name, _T("sp")) == 0) { codePage = 1252; + systLangId = MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH); localeInfo = _tsetlocale(LC_ALL, _T("Spanish")); } *************** *** 103,106 **** --- 113,117 ---- // for converting from what is read to wide characters. codePage = 1252; + systLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); localeInfo = _tsetlocale(LC_ALL, _T("English")); } *************** *** 407,414 **** --- 418,460 ---- res = libLang.insert(LibPair(lang->langName, lang)); + nbLang++; return (res.second); } /******************************************************************************** + * Get a Lang name by its system identifier. * + ********************************************************************************/ + const TCHAR *LibLang::getLang(int systLangId) { + stdext::hash_map<String,Lang*>::const_iterator res; + + res = libLang.begin(); + while (res != libLang.end()) { + if (res->second->systLangId == systLangId) + break; + res++; + } + if (res == libLang.end()) return (NULL); + return (res->second->langName.c_str()); + } + + /******************************************************************************** + * Get a Lang name by its indexe in the language library. * + ********************************************************************************/ + const TCHAR *LibLang::getLangByIndex(int index) { + stdext::hash_map<String,Lang*>::const_iterator res; + + if (index >= nbLang) + return (NULL); + + res = libLang.begin(); + while (index > 0) { + res++; + index--; + } + if (res == libLang.end()) return (NULL); + return (res->second->langName.c_str()); + } + + /******************************************************************************** * Get a Lang object by its name. * ********************************************************************************/ *************** *** 454,461 **** const TCHAR *text = curLang->get(token); if (text == NULL) { ! if (defLang != curLang) { ! text = defLang->get(token); ! } ! if (text == NULL) text = token; } --- 500,510 ---- const TCHAR *text = curLang->get(token); if (text == NULL) { ! // Use default application language if not found. ! // Note: desactivated for now, we want to see unmapped tokens to ! // complement language files. ! // if (defLang != curLang) { ! // text = defLang->get(token); ! // } ! // if (text == NULL) text = token; } |