1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #2558 from IvanSavenko/localization_fix

Do not ignore translations for maps & campaigns
This commit is contained in:
Ivan Savenko 2023-08-12 11:24:19 +03:00 committed by GitHub
commit ccf31d19f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -313,19 +313,7 @@ void CGeneralTextHandler::registerStringOverride(const std::string & modContext,
assert(!modContext.empty());
assert(!language.empty());
std::string baseModLanguage = getModLanguage(modContext);
if (baseModLanguage != language)
{
// this is translation - only add text to existing strings, do not register new ones
if (stringsLocalizations.count(UID.get()) == 0)
{
logMod->warn("Unknown string '%s' in mod '%s' for language '%s'. Ignoring", UID.get(), modContext, language);
return;
}
}
// NOTE: implicitly creates entry, intended - strings added by vcmi (and potential UI mods) are not registered anywhere at the moment
// NOTE: implicitly creates entry, intended - strings added by maps, campaigns, vcmi and potentially - UI mods are not registered anywhere at the moment
auto & entry = stringsLocalizations[UID.get()];
entry.overrideLanguage = language;
@ -349,6 +337,9 @@ bool CGeneralTextHandler::validateTranslation(const std::string & language, cons
if (string.second.baseLanguage == language && !string.second.baseValue.empty())
continue; // Base string already uses our language
if (string.second.baseLanguage.empty())
continue; // String added in localization, not present in base language (e.g. maps/campaigns)
if (config.Struct().count(string.first) > 0)
continue;