summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-10 20:31:26 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-10 20:31:26 +0300
commit011d09f618d890deffaeb79401690895bfbfaa92 (patch)
treee68321be976960c1f3d74fe9535c264b391eede7 /src
parentdde9d0d8a9b803ed5e78797ebb5ab0db5fddf662 (diff)
downloadmv-011d09f618d890deffaeb79401690895bfbfaa92.tar.gz
mv-011d09f618d890deffaeb79401690895bfbfaa92.tar.bz2
mv-011d09f618d890deffaeb79401690895bfbfaa92.tar.xz
mv-011d09f618d890deffaeb79401690895bfbfaa92.zip
Ignore fuzzy translations in poparser.
Diffstat (limited to 'src')
-rw-r--r--src/utils/translation/poparser.cpp26
-rw-r--r--src/utils/translation/poparser.h2
-rw-r--r--src/utils/translation/poparser_unittest.cc18
3 files changed, 39 insertions, 7 deletions
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index d5933fbde..c2bd3e679 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -37,7 +37,8 @@ PoParser::PoParser() :
mMsgStr(),
mDict(nullptr),
mReadingId(false),
- mReadingStr(false)
+ mReadingStr(false),
+ mSkipId(false)
{
}
@@ -163,11 +164,24 @@ bool PoParser::readMsgId()
// check line start from msgid "
if (strStartWith(mLine, msgId1))
{
- mReadingId = true;
- const size_t msgId1Size = msgId1.size();
- // reading text from: msgid "text"
- mMsgId.append(mLine.substr(msgId1Size,
- mLine.size() - 1 - msgId1Size));
+ if (!mSkipId)
+ { // translation not fuzzed and can be processed
+ mReadingId = true;
+ const size_t msgId1Size = msgId1.size();
+ // reading text from: msgid "text"
+ mMsgId.append(mLine.substr(msgId1Size,
+ mLine.size() - 1 - msgId1Size));
+ }
+ else
+ { // skipped fuzzed translation. reset skip flag
+ mSkipId = false;
+ }
+ mLine.clear();
+ return true;
+ }
+ else if (mLine == "#, fuzzy")
+ { // check for fuzzy translation
+ mSkipId = true;
mLine.clear();
return true;
}
diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h
index 436996d78..6ce5eabc7 100644
--- a/src/utils/translation/poparser.h
+++ b/src/utils/translation/poparser.h
@@ -80,6 +80,8 @@ class PoParser final
bool mReadingId;
bool mReadingStr;
+
+ bool mSkipId;
};
#endif // UTILS_TRANSLATION_POPARSER_H
diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc
index 5766f0789..1e1b527c1 100644
--- a/src/utils/translation/poparser_unittest.cc
+++ b/src/utils/translation/poparser_unittest.cc
@@ -65,7 +65,7 @@ TEST_CASE("PoParser tests", "PoParser")
REQUIRE(dict != nullptr);
REQUIRE(dict->getMap() != nullptr);
- REQUIRE(dict->getMap()->size() == 1787);
+ REQUIRE(dict->getMap()->size() == 1786);
REQUIRE(dict->getStr("Unknown skill message.") ==
"Неизвестная ошибка скилов.");
REQUIRE(dict->getStr("Full strip failed because of coating.") ==
@@ -76,4 +76,20 @@ TEST_CASE("PoParser tests", "PoParser")
delete parser;
delete dict;
}
+
+ SECTION("PoParser fuzzy")
+ {
+ PoParser *parser = new PoParser;
+ PoDict *dict = parser->load("ru",
+ "test/test1",
+ nullptr);
+
+ REQUIRE(dict != nullptr);
+ REQUIRE(dict->getMap() != nullptr);
+ REQUIRE(dict->getMap()->size() == 1786);
+ REQUIRE(dict->getStr("Atk +100%.") == "Atk +100%.");
+
+ delete parser;
+ delete dict;
+ }
}