mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed localization validation
This commit is contained in:
parent
ad87735d8d
commit
6643408cdd
@ -8,7 +8,7 @@
|
||||
"localizable" : {
|
||||
"type":"object",
|
||||
"additionalProperties" : false,
|
||||
"required" : [ "name", "description", "modType" ],
|
||||
"required" : [ "name", "description" ],
|
||||
"properties":{
|
||||
"name": {
|
||||
"type":"string",
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ bool CModHandler::validateTranslations(TModID modName) const
|
||||
|
||||
void CModHandler::loadTranslation(TModID modName)
|
||||
{
|
||||
auto & mod = allMods[modName];
|
||||
auto const & mod = allMods[modName];
|
||||
|
||||
std::string preferredLanguage = VLC->generaltexth->getPreferredLanguage();
|
||||
std::string modBaseLanguage = allMods[modName].baseLanguage;
|
||||
|
Loading…
Reference in New Issue
Block a user