1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fixed localization validation

This commit is contained in:
Ivan Savenko
2023-02-12 19:50:55 +02:00
parent ad87735d8d
commit 6643408cdd
3 changed files with 15 additions and 4 deletions

View File

@@ -418,6 +418,17 @@ void CGeneralTextHandler::registerStringOverride(const std::string & modContext,
bool CGeneralTextHandler::validateTranslation(const std::string & language, const std::string & modContext, const JsonNode & config) const
{
auto escapeString = [](std::string input)
{
boost::replace_all(input, "\\", "\\\\");
boost::replace_all(input, "\n", "\\n");
boost::replace_all(input, "\r", "\\r");
boost::replace_all(input, "\t", "\\t");
boost::replace_all(input, "\"", "\\\"");
return input;
};
bool allPresent = true;
for (auto const & string : stringsLocalizations)
@@ -440,7 +451,7 @@ bool CGeneralTextHandler::validateTranslation(const std::string & language, cons
else
currentText = string.second.overrideValue;
logMod->warn(R"( "%s" : "%s",)", string.first, currentText);
logMod->warn(R"( "%s" : "%s",)", string.first, escapeString(currentText));
allPresent = false;
}
@@ -454,7 +465,7 @@ bool CGeneralTextHandler::validateTranslation(const std::string & language, cons
if (allFound)
logMod->warn("Translation into language '%s' in mod '%s' has unused lines:", language, modContext);
logMod->warn(R"( "%s" : "%s",)", string.first, string.second.String());
logMod->warn(R"( "%s" : "%s",)", string.first, escapeString(string.second.String()));
allFound = false;
}