summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-03 16:38:27 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-03 16:38:27 +0300
commit06e87a6376180f34cf8a4cef89e98a4940ad9d08 (patch)
tree2a00b69d339edd6479fef7fa353cd4cb98e259a2 /src
parentf34a797bf750c1976c0b971dde70d77cccda96b6 (diff)
fixes #3777 (Langpack: если перевод строки отсутствует в текущем модуле, не искать его в других модулях)
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/src/Windows/langpack.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/mir_core/src/Windows/langpack.cpp b/src/mir_core/src/Windows/langpack.cpp
index 010b1311ca..a71d3dabb2 100644
--- a/src/mir_core/src/Windows/langpack.cpp
+++ b/src/mir_core/src/Windows/langpack.cpp
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define LANGPACK_BUF_SIZE 4000
+static MUUID emptyMuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
+
static int CompareMuuids(const MUUID *p1, const MUUID *p2)
{
return memcmp(p1, p2, sizeof(MUUID));
@@ -47,6 +49,20 @@ struct LangPackEntry
wchar_t *wszLocal;
MUUID *pMuuid;
LangPackEntry* pNext; // for langpack items with the same hash value
+
+ LangPackEntry* findNearest(const MUUID *pUuid)
+ {
+ if (pUuid)
+ for (auto *p = this; p != nullptr; p = p->pNext)
+ if (p->pMuuid && *p->pMuuid == *pUuid)
+ return p;
+
+ for (auto *p = this; p != nullptr; p = p->pNext)
+ if (p->pMuuid == nullptr)
+ return p;
+
+ return nullptr;
+ }
};
static LANGPACK_INFO langPack;
@@ -149,7 +165,11 @@ static const MUUID* GetMuid(HPLUGIN pPlugin)
return nullptr;
__try {
- return &pPlugin->getInfo().uuid;
+ auto &pMuuid = pPlugin->getInfo().uuid;
+ if (pMuuid == emptyMuid)
+ return nullptr;
+
+ return &pMuuid;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -486,15 +506,9 @@ char* LangPackTranslateString(const MUUID *pUuid, const char *szEnglish, const i
if (entry == nullptr)
return (char*)szEnglish;
- // try to find the exact match, otherwise the first entry will be returned
- if (pUuid) {
- for (LangPackEntry *p = entry->pNext; p != nullptr; p = p->pNext) {
- if (p->pMuuid && *p->pMuuid == *pUuid) {
- entry = p;
- break;
- }
- }
- }
+ entry = entry->findNearest(pUuid);
+ if (entry == nullptr)
+ return (char *)szEnglish;
switch (W) {
case 0: