From da825236d558418c8a5a7137cd7e6e3a7312d159 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Feb 2015 20:41:30 +0000 Subject: one more way to detect the default language, if it's not specified in mirandaboot.ini git-svn-id: http://svn.miranda-ng.org/main/trunk@12025 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/commonheaders.h | 3 --- src/mir_core/src/langpack.cpp | 30 +++++++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/commonheaders.h b/src/mir_core/src/commonheaders.h index 87a26ebd2c..cb5fea518a 100644 --- a/src/mir_core/src/commonheaders.h +++ b/src/mir_core/src/commonheaders.h @@ -63,7 +63,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include - -extern TCHAR tszDefaultLang[100]; - void GetDefaultLang(); \ No newline at end of file diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp index aa6d9f9d86..0cbe25e91c 100644 --- a/src/mir_core/src/langpack.cpp +++ b/src/mir_core/src/langpack.cpp @@ -634,8 +634,6 @@ MIR_CORE_DLL(void) Langpack_SortDuplicates(void) ///////////////////////////////////////////////////////////////////////////////////////// -TCHAR tszDefaultLang[100]; - void GetDefaultLang() { // calculate the langpacks' root @@ -644,17 +642,27 @@ void GetDefaultLang() PathToAbsoluteT(_T("."), g_tszRoot); // look into mirandaboot.ini - TCHAR tszPath[MAX_PATH]; + TCHAR tszPath[MAX_PATH], tszLangName[256]; PathToAbsoluteT(_T("\\mirandaboot.ini"), tszPath); - GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), tszPath); - - if (!mir_tstrcmpi(tszDefaultLang, _T("default"))) { - db_set_ts(NULL, "Langpack", "Current", _T("default")); - return; + GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszLangName, SIZEOF(tszLangName), tszPath); + if (tszLangName[0]) { + if (!mir_tstrcmpi(tszLangName, _T("default"))) { + db_set_ts(NULL, "Langpack", "Current", _T("default")); + return; + } + if (!LoadLangPack(tszLangName)) { + db_set_ts(NULL, "Langpack", "Current", tszLangName); + return; + } } - else if (!LoadLangPack(tszDefaultLang)) { - db_set_ts(NULL, "Langpack", "Current", tszDefaultLang); - return; + + // try to load langpack that matches UserDefaultUILanguage + if (GetLocaleInfo(MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, tszLangName, SIZEOF(tszLangName))) { + mir_sntprintf(tszPath, SIZEOF(tszPath), _T("langpack_%s.txt"), _tcslwr(tszLangName)); + if (!LoadLangPack(tszPath)) { + db_set_ts(NULL, "Langpack", "Current", tszPath); + return; + } } // finally try to load first file -- cgit v1.2.3