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 | |
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')
-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 | ||||
-rw-r--r-- | src/modules/langpack/langpack.cpp | 2 | ||||
-rw-r--r-- | src/modules/langpack/lpopts.cpp | 4 |
5 files changed, 37 insertions, 16 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;
}
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp index 33a52b53d0..30f9f1dcf7 100644 --- a/src/modules/langpack/langpack.cpp +++ b/src/modules/langpack/langpack.cpp @@ -76,7 +76,7 @@ BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam) pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF));
/* file date */
if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) {
- lstrcpy(pack.tszFileName, _tcsrchr(pack.tszFullPath, '\\') + 1);
+ lstrcpy(pack.tszFileName, _T("default"));
HANDLE hFile = CreateFile(pack.tszFileName, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE) {
GetFileTime(hFile, NULL, NULL, &pack.ftFileDate);
diff --git a/src/modules/langpack/lpopts.cpp b/src/modules/langpack/lpopts.cpp index b1c11ae665..5ea238b859 100644 --- a/src/modules/langpack/lpopts.cpp +++ b/src/modules/langpack/lpopts.cpp @@ -166,7 +166,9 @@ INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP for (int i = 0; i < count; i++) {
LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, i);
if (i == idx) {
- db_set_ws(NULL, "Langpack", "Current", pack->tszFileName);
+ db_set_ts(NULL, "Langpack", "Current", pack->tszFileName);
+ PathToAbsoluteT(_T("\\mirandaboot.ini"), tszPath);
+ WritePrivateProfileString(_T("Language"), _T("DefaultLanguage"), pack->tszFileName, tszPath);
lstrcpy(tszPath, pack->tszFullPath);
pack->flags |= LPF_ENABLED;
}
|