diff options
author | George Hazan <george.hazan@gmail.com> | 2015-02-06 20:41:30 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-02-06 20:41:30 +0000 |
commit | da825236d558418c8a5a7137cd7e6e3a7312d159 (patch) | |
tree | 2b3ce967dce9c20a58d24e469b95343ef57b1512 /src | |
parent | f15f4d589ab7e2ad7f4112c42f83edcee8924482 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/src/commonheaders.h | 3 | ||||
-rw-r--r-- | src/mir_core/src/langpack.cpp | 30 |
2 files changed, 19 insertions, 14 deletions
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 <m_ssl.h>
#include <m_xml.h>
-
-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
|