From 3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 Apr 2017 19:03:59 +0300 Subject: Add chat command for translate message from player language to english. Also add po field into languages.xml. --- src/resources/db/languagedb.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/resources/db/languagedb.cpp') diff --git a/src/resources/db/languagedb.cpp b/src/resources/db/languagedb.cpp index e4bbffea4..b7e3ebc0e 100644 --- a/src/resources/db/languagedb.cpp +++ b/src/resources/db/languagedb.cpp @@ -31,7 +31,9 @@ namespace { std::string mDefaultIcon; - std::map mLanguages; + std::string mDefaultPo; + std::map mIcons; + std::map mPo; } // namespace void LanguageDb::load() @@ -74,7 +76,23 @@ void LanguageDb::loadXmlFile(const std::string &fileName, continue; } const std::string icon = XML::getProperty(node, "icon", ""); - mLanguages[id] = icon; + const std::string po = XML::getProperty(node, "po", ""); + if (icon.empty()) + { + reportAlways("LanguageDb: empty icon field"); + } + else + { + mIcons[id] = icon; + } + if (po.empty()) + { + reportAlways("LanguageDb: empty po field"); + } + else + { + mPo[id] = po; + } } } @@ -83,13 +101,22 @@ void LanguageDb::loadXmlFile(const std::string &fileName, void LanguageDb::unload() { - mLanguages.clear(); + mIcons.clear(); + mPo.clear(); } const std::string &LanguageDb::getIcon(const int id) { - std::map::const_iterator it = mLanguages.find(id); - if (it == mLanguages.end()) + std::map::const_iterator it = mIcons.find(id); + if (it == mIcons.end()) return mDefaultIcon; return (*it).second; } + +const std::string &LanguageDb::getPo(const int id) +{ + std::map::const_iterator it = mPo.find(id); + if (it == mPo.end()) + return mDefaultPo; + return (*it).second; +} -- cgit v1.2.3-70-g09d2