From 47ffc74ce482ec3a5ee00ae6ea2d6b101510cff1 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Thu, 1 Aug 2013 21:52:32 +0100 Subject: [PATCH] Fixes to masterlist parser and generator. --- src/backend/generators.h | 17 ++++++++--------- src/backend/parsers.h | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/backend/generators.h b/src/backend/generators.h index 2d3737ff..e3a6555b 100644 --- a/src/backend/generators.h +++ b/src/backend/generators.h @@ -565,17 +565,13 @@ namespace YAML { } inline Emitter& operator << (Emitter& out, const boss::MessageContent& rhs) { - if (rhs.Language() == boss::g_lang_any) - out << rhs.Str(); - else { - out << BeginMap; + out << BeginMap; - out << Key << "lang" << Value << boss::GetLangString(rhs.Language()); + out << Key << "lang" << Value << boss::GetLangString(rhs.Language()); - out << Key << "str" << Value << rhs.Str(); + out << Key << "str" << Value << rhs.Str(); - out << EndMap; - } + out << EndMap; } inline Emitter& operator << (Emitter& out, const boss::Message& rhs) { @@ -588,7 +584,10 @@ namespace YAML { else out << Key << "type" << Value << "error"; - out << Key << "content" << Value << rhs.Content(); + if (rhs.Content().size() == 1 && rhs.Content().front().Language() == boss::g_lang_any) + out << Key << "content" << Value << rhs.Content().front().Str(); + else + out << Key << "content" << Value << rhs.Content(); if (!rhs.Condition().empty()) out << Key << "condition" << Value << rhs.Condition(); diff --git a/src/backend/parsers.h b/src/backend/parsers.h index 96933534..cc27ab6c 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -167,8 +167,9 @@ namespace YAML { std::vector content; if (node["content"].IsSequence()) content = node["content"].as< std::vector >(); - else - content.push_back(node["content"].as()); + else { + content.push_back(boss::MessageContent(node["content"].as())); + } //Check now that at least one item in content is English if there are multiple items. if (content.size() > 1) { @@ -177,9 +178,8 @@ namespace YAML { if (it->Language() == boss::g_lang_english) found = true; } - //Commented out because the auto-converted masterlist has localisations as separate messages and so will always fail. - // if (!found) - // return false; + if (!found) + return false; } std::string condition;