diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-19 22:50:40 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-19 22:50:40 +0300 |
commit | b4dc014b107f871ee9a7dfbcd3ca5539dd3aa73e (patch) | |
tree | 30209d79daf76f3876e721f0445f7b412c9ce607 | |
parent | 5797df55a7e19fac3874429bf753a57e8daef970 (diff) |
TranslateU - translates a string to Utf8
-rw-r--r-- | include/m_langpack.h | 2 | ||||
-rw-r--r-- | libs/win32/mir_core.lib | bin | 451916 -> 452126 bytes | |||
-rw-r--r-- | libs/win64/mir_core.lib | bin | 456798 -> 456990 bytes | |||
-rw-r--r-- | src/mir_core/src/langpack.cpp | 30 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 |
6 files changed, 27 insertions, 7 deletions
diff --git a/include/m_langpack.h b/include/m_langpack.h index ed0f0019f2..4bcb92d8e5 100644 --- a/include/m_langpack.h +++ b/include/m_langpack.h @@ -46,10 +46,12 @@ EXTERN_C MIR_CORE_DLL(int) LoadLangPack(const wchar_t *szLangPack); EXTERN_C MIR_CORE_DLL(void) ReloadLangpack(wchar_t *pszStr);
EXTERN_C MIR_CORE_DLL(char*) TranslateA_LP(const char *str, HPLUGIN = nullptr);
+EXTERN_C MIR_CORE_DLL(char*) TranslateU_LP(const char *str, HPLUGIN = nullptr);
EXTERN_C MIR_CORE_DLL(wchar_t*) TranslateW_LP(const wchar_t *str, HPLUGIN = nullptr);
EXTERN_C MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, HPLUGIN = nullptr);
#define Translate(s) TranslateA_LP(s, &g_plugin)
+#define TranslateU(s) TranslateU_LP(s, &g_plugin)
#define TranslateW(s) TranslateW_LP(s, &g_plugin)
#define TranslateT(s) TranslateW_LP(_A2W(s), &g_plugin)
#define TranslateDialogDefault(h) TranslateDialog_LP(h, &g_plugin)
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib Binary files differindex 6155ccc984..6894d194d3 100644 --- a/libs/win32/mir_core.lib +++ b/libs/win32/mir_core.lib diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib Binary files differindex 01e94d0796..882ec4ed8c 100644 --- a/libs/win64/mir_core.lib +++ b/libs/win64/mir_core.lib diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp index fab4656a63..0532f58e4a 100644 --- a/src/mir_core/src/langpack.cpp +++ b/src/mir_core/src/langpack.cpp @@ -43,6 +43,7 @@ struct LangPackEntry {
DWORD englishHash;
char *szLocal;
+ char *utfLocal;
wchar_t *wszLocal;
MUUID *pMuuid;
LangPackEntry* pNext; // for langpack items with the same hash value
@@ -480,7 +481,7 @@ char* LangPackTranslateString(const MUUID *pUuid, const char *szEnglish, const i return (char*)szEnglish;
LangPackEntry key, *entry;
- key.englishHash = W ? hashstrW(szEnglish) : mir_hashstr(szEnglish);
+ key.englishHash = (W == 1) ? hashstrW(szEnglish) : mir_hashstr(szEnglish);
entry = (LangPackEntry*)bsearch(&key, g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2);
if (entry == nullptr)
return (char*)szEnglish;
@@ -495,12 +496,22 @@ char* LangPackTranslateString(const MUUID *pUuid, const char *szEnglish, const i }
}
- if (W)
+ switch (W) {
+ case 0:
+ if (entry->szLocal == nullptr && entry->wszLocal != nullptr)
+ entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.codepage);
+ return entry->szLocal;
+
+ case 1:
return (char*)entry->wszLocal;
- if (entry->szLocal == nullptr && entry->wszLocal != nullptr)
- entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.codepage);
- return entry->szLocal;
+ case 2:
+ if (entry->utfLocal == nullptr && entry->wszLocal != nullptr)
+ entry->utfLocal = mir_utf8encodeW(entry->wszLocal);
+ return entry->utfLocal;
+ }
+
+ return nullptr;
}
MIR_CORE_DLL(int) Langpack_GetDefaultCodePage()
@@ -529,12 +540,17 @@ MIR_CORE_DLL(wchar_t*) Langpack_PcharToTchar(const char *pszStr) MIR_CORE_DLL(char*) TranslateA_LP(const char *str, HPLUGIN pPlugin)
{
- return (char*)LangPackTranslateString(GetMuid(pPlugin), str, FALSE);
+ return (char*)LangPackTranslateString(GetMuid(pPlugin), str, 0);
+}
+
+MIR_CORE_DLL(char*) TranslateU_LP(const char *str, HPLUGIN pPlugin)
+{
+ return (char*)LangPackTranslateString(GetMuid(pPlugin), str, 2);
}
MIR_CORE_DLL(wchar_t*) TranslateW_LP(const wchar_t *str, HPLUGIN pPlugin)
{
- return (wchar_t*)LangPackTranslateString(GetMuid(pPlugin), (LPCSTR)str, TRUE);
+ return (wchar_t*)LangPackTranslateString(GetMuid(pPlugin), (LPCSTR)str, 1);
}
MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, HPLUGIN pPlugin)
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 1fafa5915d..91ca5b7dbd 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1419,3 +1419,4 @@ db_get_utfa @1631 ?GetTextU@CCtrlBase@@QAEPADPADI@Z @1632 NONAME
?GetTextU@CCtrlBase@@QAEPADXZ @1633 NONAME
?BytesParsed@XMLDocument@tinyxml2@@QBEHXZ @1634 NONAME
+TranslateU_LP @1635
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index f395c92786..565fd9bedc 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1419,3 +1419,4 @@ db_get_utfa @1631 ?GetTextU@CCtrlBase@@QEAAPEADPEAD_K@Z @1632 NONAME
?GetTextU@CCtrlBase@@QEAAPEADXZ @1633 NONAME
?BytesParsed@XMLDocument@tinyxml2@@QEBAHXZ @1634 NONAME
+TranslateU_LP @1635
|