summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-02 19:23:33 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-02 21:35:07 +0300
commit2a9ac5ea06d22e459762295546e88d76b835f552 (patch)
tree619d93de71312c94ee7fa7bc87edb9124a676d9c /src/utils
parenta65d9da124346f6cec0ac679c689bf6dd0ce34e8 (diff)
downloadmanaverse-2a9ac5ea06d22e459762295546e88d76b835f552.tar.gz
manaverse-2a9ac5ea06d22e459762295546e88d76b835f552.tar.bz2
manaverse-2a9ac5ea06d22e459762295546e88d76b835f552.tar.xz
manaverse-2a9ac5ea06d22e459762295546e88d76b835f552.zip
Add basic support for skiping plurals and use default translation.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/translation/poparser.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index ba07a490a..d5933fbde 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -120,6 +120,12 @@ bool PoParser::readLine()
char line[1001];
if (!mFile.getline(line, 1000))
return false;
+ // skip plurals msgid if present
+ if (strStartWith(line, "msgid_plural \""))
+ {
+ if (!mFile.getline(line, 1000))
+ return false;
+ }
mLine = line;
return true;
}
@@ -172,7 +178,10 @@ bool PoParser::readMsgId()
bool PoParser::readMsgStr()
{
+ // normal msgstr
const std::string msgStr1("msgstr \"");
+ // plurals first msgstr
+ const std::string msgStr2("msgstr[0] \"");
// check if in reading process
if (mReadingStr)
@@ -200,12 +209,23 @@ bool PoParser::readMsgStr()
{
mReadingStr = true;
const size_t msgStr1Size = msgStr1.size();
- // reading text from: msgid "text"
+ // reading text from: msgstr "text"
mMsgStr.append(mLine.substr(msgStr1Size,
mLine.size() - 1 - msgStr1Size));
mLine.clear();
return true;
}
+ // checl list start from msgstr[0] "
+ else if (strStartWith(mLine, msgStr2))
+ {
+ mReadingStr = true;
+ const size_t msgStr2Size = msgStr2.size();
+ // reading text from: msgstr[0] "text"
+ mMsgStr.append(mLine.substr(msgStr2Size,
+ mLine.size() - 1 - msgStr2Size));
+ mLine.clear();
+ return true;
+ }
}
// stop reading in other case