summaryrefslogtreecommitdiff
path: root/src/resources/db
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
parentd8a530e299b4dd04c020ca3e3eeda7b12f89b69b (diff)
downloadmanaverse-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.gz
manaverse-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.bz2
manaverse-3b4ffd7199d990d1cbd0e7cbe23fa41f04d38e74.tar.xz
manaverse-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')
-rw-r--r--src/resources/db/languagedb.cpp37
-rw-r--r--src/resources/db/languagedb.h2
2 files changed, 34 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;
+}
diff --git a/src/resources/db/languagedb.h b/src/resources/db/languagedb.h
index 18302a451..8f33576a6 100644
--- a/src/resources/db/languagedb.h
+++ b/src/resources/db/languagedb.h
@@ -37,6 +37,8 @@ namespace LanguageDb
void unload();
const std::string &getIcon(const int id);
+
+ const std::string &getPo(const int id);
} // namespace LanguageDB
#endif // RESOURCES_DB_LANGUAGEDB_H