summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-19 18:38:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-19 18:38:17 +0300
commit5a6379badc14cadb6169c946bfadbab1d16d54be (patch)
treefbc77fe96a687577414174a90ee080dfaf864281 /src/mir_core
parentd83705fff3f3d3bc25dd352f644847e250d4b65e (diff)
Language pack loader to call GetLocaleInfo() only if language name is missing
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/langpack.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp
index e20a465051..5e6f4ad62b 100644
--- a/src/mir_core/src/langpack.cpp
+++ b/src/mir_core/src/langpack.cpp
@@ -310,6 +310,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start
lpinfo.codepage = CP_ACP;
lpinfo.flags = 0;
+ lpinfo.tszLanguage[0] = 0;
fgets(line, LANGPACK_BUF_SIZE, fp);
size_t lineLen = strlen(line);
@@ -365,9 +366,13 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start
lpinfo.szAuthors = szAuthors;
- MultiByteToWideChar(lpinfo.codepage, 0, szLanguage, -1, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage));
+ ptrW buf(Utf8DecodeW(szLanguage));
+ if (buf)
+ wcsncpy_s(lpinfo.tszLanguage, buf, _TRUNCATE);
+ else if (lpinfo.Locale != 0)
+ GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage));
- if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage))) {
+ if (!lpinfo.tszLanguage[0]) {
wchar_t *p = wcschr(lpinfo.tszFileName, '_');
wcsncpy_s(lpinfo.tszLanguage, ((p != nullptr) ? (p + 1) : lpinfo.tszFileName), _TRUNCATE);
p = wcsrchr(lpinfo.tszLanguage, '.');