char* LangPackTranslateString(MUUID *pUuid, const char *szEnglish, const int W) { if (g_entryCount == 0 || szEnglish == NULL) return (char*)szEnglish; LangPackEntry key, *entry; key.englishHash = W ? hashstrW(szEnglish) : mir_hashstr(szEnglish); entry = (LangPackEntry*)bsearch(&key, g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2); if (entry == NULL) return (char*)szEnglish; // try to find the exact match, otherwise the first entry will be returned if (pUuid) { for (LangPackEntry *p = entry->pNext; p != NULL; p = p->pNext) { if (p->pMuuid == pUuid) { entry = p; break; } } } if (W) return (char*)entry->wszLocal; if (entry->szLocal == NULL && entry->wszLocal != NULL) entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.codepage); return entry->szLocal; }
char *LangPackTranslateString(const char *szEnglish, const int W) { struct LangPackEntry key,*entry; if ( langPack.entryCount == 0 || szEnglish == NULL ) return (char*)szEnglish; key.englishHash = W ? hashstrW(szEnglish) : hashstr(szEnglish); entry=(struct LangPackEntry*)bsearch(&key,langPack.entry,langPack.entryCount,sizeof(struct LangPackEntry),(int(*)(const void*,const void*))SortLangPackHashesProc2); if(entry==NULL) return (char*)szEnglish; while(entry>langPack.entry) { entry--; if(entry->englishHash!=key.englishHash) { entry++; return W ? (char *)entry->wlocal : entry->local; } } return W ? (char *)entry->wlocal : entry->local; }