summaryrefslogtreecommitdiff
path: root/src/utils/translation/poparser.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-18 23:05:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-19 00:03:33 +0300
commitf99ee017f2ac6b03a6bc6122cb78923a9b4f6a5f (patch)
treeb325f2fa7063581f3110184aa449d08c9fafbb02 /src/utils/translation/poparser.cpp
parentac9594ec37a52c436b87a2d431e7df126592e4a5 (diff)
downloadmanaverse-f99ee017f2ac6b03a6bc6122cb78923a9b4f6a5f.tar.gz
manaverse-f99ee017f2ac6b03a6bc6122cb78923a9b4f6a5f.tar.bz2
manaverse-f99ee017f2ac6b03a6bc6122cb78923a9b4f6a5f.tar.xz
manaverse-f99ee017f2ac6b03a6bc6122cb78923a9b4f6a5f.zip
Add help po translation.
Combine help and client data translations.
Diffstat (limited to 'src/utils/translation/poparser.cpp')
-rw-r--r--src/utils/translation/poparser.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index 521774592..d0f79a28c 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -24,7 +24,6 @@
#include "utils/stringutils.h"
-#include "localconsts.h"
#include "logger.h"
#include <string.h>
@@ -39,22 +38,30 @@ PoParser::PoParser() :
{
}
-void PoParser::openFile()
+void PoParser::openFile(std::string name)
{
ResourceManager *resman = ResourceManager::getInstance();
int size;
- char *buf = static_cast<char*>(resman->loadFile(getFileName(mLang), size));
+ char *buf = static_cast<char*>(resman->loadFile(getFileName(name), size));
mFile.str(std::string(buf, size));
free(buf);
}
-PoDict *PoParser::load(std::string lang)
+PoDict *PoParser::load(std::string lang, std::string fileName, PoDict *dict)
{
+ logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
+
setLang(lang);
- mDict = getDict();
+ if (!dict)
+ mDict = getDict();
+ else
+ mDict = dict;
- openFile();
+ if (fileName.empty())
+ openFile(mLang);
+ else
+ openFile(fileName);
mMsgId = "";
mMsgStr = "";
@@ -84,6 +91,8 @@ PoDict *PoParser::load(std::string lang)
// logger->log("add key: " + mMsgId);
// logger->log("add value: " + mMsgStr);
+ convertStr(mMsgId);
+ convertStr(mMsgStr);
// store key and value
mDict->set(mMsgId, mMsgStr);
}
@@ -212,6 +221,7 @@ bool PoParser::checkLang(std::string lang) const
std::string PoParser::getFileName(std::string lang) const
{
// get po file name from lang name
+ logger->log("getFileName: translations/%s.po", lang.c_str());
return strprintf("translations/%s.po", lang.c_str());
}
@@ -219,3 +229,13 @@ PoDict *PoParser::getDict()
{
return new PoDict(mLang);
}
+
+void PoParser::convertStr(std::string &str)
+{
+ if (str.empty())
+ return;
+
+ replaceAll(str, "\\n", "\n");
+ replaceAll(str, "\\\"", "\"");
+ replaceAll(str, "\\\\", "\\");
+}