From 2a9ac5ea06d22e459762295546e88d76b835f552 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Jan 2016 19:23:33 +0300 Subject: Add basic support for skiping plurals and use default translation. --- src/utils/translation/poparser.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/utils/translation/poparser.cpp') 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 -- cgit v1.2.3-70-g09d2