summaryrefslogtreecommitdiff
path: root/src/resources/db/languagedb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-05 19:03:59 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-05 19:03:59 +0300
commit3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74 (patch)
treefe7ab920632207462354714e12604e2064d059ea /src/resources/db/languagedb.cpp
parentd8a530e299b4dd04c020ca3e3eeda7b12f89b69b (diff)
downloadplus-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.gz
plus-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.bz2
plus-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.xz
plus-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.zip
Add chat command for translate message from player language to english.
Also add po field into languages.xml.
Diffstat (limited to 'src/resources/db/languagedb.cpp')
-rw-r--r--src/resources/db/languagedb.cpp37
1 files changed, 32 insertions, 5 deletions
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<int, std::string> mLanguages;
+ std::string mDefaultPo;
+ std::map<int, std::string> mIcons;
+ std::map<int, std::string> 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<int, std::string>::const_iterator it = mLanguages.find(id);
- if (it == mLanguages.end())
+ std::map<int, std::string>::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<int, std::string>::const_iterator it = mPo.find(id);
+ if (it == mPo.end())
+ return mDefaultPo;
+ return (*it).second;
+}