summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/translations/test/test1.po1
-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
4 files changed, 40 insertions, 7 deletions
diff --git a/data/translations/test/test1.po b/data/translations/test/test1.po
index 541ee2af8..bc7fc452e 100644
--- a/data/translations/test/test1.po
+++ b/data/translations/test/test1.po
@@ -10092,6 +10092,7 @@ msgstr "Защита +25%."
#. TRANSLATORS: notification message
#: src/resources/notifications.h:694
+#, fuzzy
msgid "Atk +100%."
msgstr "Атака +100%."
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;
+ }
}