diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-08 19:55:34 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-08 19:55:34 +0000 |
commit | 39bd74cbd4d2dbe536d003c15d17f5eefd572394 (patch) | |
tree | f5c5f388eb6a85511edfb202fdff34ec36d2938b /src/mir_core | |
parent | b452546a225e5c527a0380516440fd6b291a9463 (diff) |
fixed writing current langpack in db
git-svn-id: http://svn.miranda-ng.org/main/trunk@10130 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/commonheaders.h | 5 | ||||
-rw-r--r-- | src/mir_core/db.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/langpack.cpp | 40 |
3 files changed, 33 insertions, 14 deletions
diff --git a/src/mir_core/commonheaders.h b/src/mir_core/commonheaders.h index 31745ac0a8..083ccd8e87 100644 --- a/src/mir_core/commonheaders.h +++ b/src/mir_core/commonheaders.h @@ -62,3 +62,8 @@ 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/db.cpp b/src/mir_core/db.cpp index e87c371898..9fc57870ad 100644 --- a/src/mir_core/db.cpp +++ b/src/mir_core/db.cpp @@ -359,6 +359,8 @@ extern "C" MIR_CORE_DLL(void) db_setCurrent(MIDatabase *_db) ptrT langpack(db_get_tsa(NULL, "Langpack", "Current"));
if (langpack && langpack[0] != '\0')
LoadLangPack(langpack);
+ else
+ GetDefaultLang();
}
MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable)
diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp index 435f7cb825..edbacee4b2 100644 --- a/src/mir_core/langpack.cpp +++ b/src/mir_core/langpack.cpp @@ -373,7 +373,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start MIR_CORE_DLL(int) LoadLangPack(const TCHAR *ptszLangPack)
{
- if (ptszLangPack == NULL)
+ if (ptszLangPack == NULL || !lstrcmpi(ptszLangPack, _T("")))
return 1;
// ensure that a lang's name is a full file name
@@ -634,23 +634,28 @@ MIR_CORE_DLL(void) Langpack_SortDuplicates(void) /////////////////////////////////////////////////////////////////////////////////////////
-MIR_CORE_DLL(int) LoadLangPackModule(void)
-{
- bModuleInitialized = TRUE;
-
- hevChanged = CreateHookableEvent(ME_LANGPACK_CHANGED);
+TCHAR tszDefaultLang[100];
+void GetDefaultLang()
+{
// calculate the langpacks' root
PathToAbsoluteT(_T("\\Languages"), g_tszRoot);
if (_taccess(g_tszRoot, 0) != 0) // directory Languages exists
PathToAbsoluteT(_T("."), g_tszRoot);
// look into mirandaboot.ini
- TCHAR tszDefaultLang[100], tszPath[MAX_PATH];
+ TCHAR tszPath[MAX_PATH];
PathToAbsoluteT(_T("\\mirandaboot.ini"), tszPath);
- if (GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), tszPath))
- if (!LoadLangPack(tszDefaultLang))
- return 0;
+ GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), tszPath);
+
+ if (!lstrcmpi(tszDefaultLang, _T("default"))) {
+ db_set_ts(NULL, "Langpack", "Current", _T("default"));
+ return;
+ }
+ else if (!LoadLangPack(tszDefaultLang)) {
+ db_set_ts(NULL, "Langpack", "Current", tszDefaultLang);
+ return;
+ }
// finally try to load first file
mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\langpack_*.txt"), g_tszRoot);
@@ -662,15 +667,22 @@ MIR_CORE_DLL(int) LoadLangPackModule(void) /* search first langpack that could be loaded */
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
-
+
if (!LoadLangPack(fd.cFileName)) {
db_set_ts(NULL, "Langpack", "Current", fd.cFileName);
break;
}
- }
- while (FindNextFile(hFind, &fd));
+ } while (FindNextFile(hFind, &fd));
FindClose(hFind);
- }
+ } else
+ db_set_ts(NULL, "Langpack", "Current", _T("default"));
+}
+
+MIR_CORE_DLL(int) LoadLangPackModule(void)
+{
+ bModuleInitialized = TRUE;
+ hevChanged = CreateHookableEvent(ME_LANGPACK_CHANGED);
+ GetDefaultLang();
return 0;
}
|