diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-23 21:16:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-23 21:16:11 +0000 |
commit | d8a81a7a63b37b760d5c22641ed4f4b1cfbb232a (patch) | |
tree | a7494e040b919b674d4e26d572efd58ef45d0f49 /src/modules/langpack/langpack.cpp | |
parent | 53be8fe2c490da232c7ec7e87c1a5d65a1215241 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8725 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/langpack/langpack.cpp')
-rw-r--r-- | src/modules/langpack/langpack.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp index 80fa824b01..9d6f1fc914 100644 --- a/src/modules/langpack/langpack.cpp +++ b/src/modules/langpack/langpack.cpp @@ -101,33 +101,43 @@ void Langpack_LoadLangpack(void) TCHAR szSearch[MAX_PATH];
PathToAbsoluteT(_T("\\"), szSearch);
- /* try to load langpack */
+ // try to get the langpack's name from a profile first
ptrT langpack(db_get_tsa(NULL, "Langpack", "Current"));
if (langpack && langpack[0] != '\0') {
lstrcat(szSearch, langpack);
DWORD dwAttrib = GetFileAttributes(szSearch);
- if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
+ if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
LoadLangPack(szSearch);
- }
- /* else try to load first file */
- else if (!langpack) {
- lstrcat(szSearch, _T("langpack_*.txt"));
-
- WIN32_FIND_DATA fd;
- HANDLE hFind = FindFirstFile(szSearch, &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- /* search first langpack that could be loaded */
- if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
- /* load langpack */
- PathToAbsoluteT(_T("\\"), szSearch);
- lstrcat(szSearch, fd.cFileName);
- if (!LoadLangPack(szSearch))
- db_set_ws(NULL, "Langpack", "Current", fd.cFileName);
- break;
- } while (FindNextFile(hFind, &fd));
- FindClose(hFind);
+ return;
}
}
+
+ // look into mirandaboot.ini
+ TCHAR tszDefaultLang[100];
+ if (GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), mirandabootini)) {
+ TCHAR tszLangPath[MAX_PATH];
+ PathToAbsoluteT(tszDefaultLang, tszLangPath);
+ LoadLangPack(tszLangPath);
+ return;
+ }
+
+ // finally try to load first file
+ lstrcat(szSearch, _T("langpack_*.txt"));
+
+ WIN32_FIND_DATA fd;
+ HANDLE hFind = FindFirstFile(szSearch, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ /* search first langpack that could be loaded */
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
+ /* load langpack */
+ PathToAbsoluteT(_T("\\"), szSearch);
+ lstrcat(szSearch, fd.cFileName);
+ if (!LoadLangPack(szSearch))
+ db_set_ws(NULL, "Langpack", "Current", fd.cFileName);
+ break;
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
}
|