Localize: add language codes

Newly added g_LanguageCodes maps directly with g_LanguageNames.
This commit is contained in:
Kawe Mazidjatari 2024-05-07 16:00:20 +02:00
parent f0fe2bf58f
commit 36824629fe
3 changed files with 34 additions and 10 deletions

View File

@ -32,13 +32,7 @@ bool Localize_LoadLocalizationFileLists(CLocalize* thisptr)
bool Localize_IsLanguageSupported(const char* pLocaleName)
{
for (int i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); ++i)
{
if (strcmp(pLocaleName, g_LanguageNames[i]) == NULL)
return true;
}
return false;
return V_LocaleNameExists(pLocaleName);
}
void VLocalize::Detour(const bool bAttach) const

View File

@ -65,6 +65,7 @@ inline const char* const g_LanguageNames[] = {
"italian",
"korean",
"spanish",
"mspanish",
"schinese",
"tchinese",
"russian",
@ -73,11 +74,40 @@ inline const char* const g_LanguageNames[] = {
"polish",
};
inline bool V_LocaleExists(const char* const pLocale)
inline const char* const g_LanguageCodes[] = {
"en_US",
"de_DE",
"fr_FR",
"it_IT",
"ko_KR",
"es_ES",
"es_MX",
"zh_CN",
"zh_TW",
"ru_RU",
"ja_JP",
"pt_BR",
"pl_PL",
};
inline bool V_LocaleNameExists(const char* const localeName)
{
for (size_t i = 0; i < V_ARRAYSIZE(g_LanguageNames); i++)
{
if (V_strcmp(pLocale, g_LanguageNames[i]) == NULL)
if (V_strcmp(localeName, g_LanguageNames[i]) == NULL)
{
return true;
}
}
return false;
}
inline bool V_LocaleCodeExists(const char* const localeCode)
{
for (size_t i = 0; i < V_ARRAYSIZE(g_LanguageCodes); i++)
{
if (V_strcmp(localeCode, g_LanguageCodes[i]) == NULL)
{
return true;
}

View File

@ -799,7 +799,7 @@ VPKChunkDescriptor_t::VPKChunkDescriptor_t(uint32_t nLoadFlags, uint16_t nTextur
//-----------------------------------------------------------------------------
VPKPair_t::VPKPair_t(const char* pLocale, const char* pTarget, const char* pLevel, int nPatch)
{
const bool bFoundLocale = V_LocaleExists(pLocale);
const bool bFoundLocale = V_LocaleNameExists(pLocale);
if (!bFoundLocale)
{