summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-03 18:20:50 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-03 18:20:50 +0300
commitcce2dab67a0f4ea6996587d8d57f679a5e0286e6 (patch)
tree234cc68aa85d632c4fa2e7e2a9d263cc9f89ebc2
parentb9f034639f3371187a95c9a6ed859948fcccd72a (diff)
downloadmplint-cce2dab67a0f4ea6996587d8d57f679a5e0286e6.tar.gz
mplint-cce2dab67a0f4ea6996587d8d57f679a5e0286e6.tar.bz2
mplint-cce2dab67a0f4ea6996587d8d57f679a5e0286e6.tar.xz
mplint-cce2dab67a0f4ea6996587d8d57f679a5e0286e6.zip
Add support for check firs char in translations (po files).
-rw-r--r--src/rules/po.cpp46
-rw-r--r--tests/testreport.txt1
2 files changed, 33 insertions, 14 deletions
diff --git a/src/rules/po.cpp b/src/rules/po.cpp
index f0d743f..d600d19 100644
--- a/src/rules/po.cpp
+++ b/src/rules/po.cpp
@@ -61,9 +61,11 @@ static void processMessage(RuleBase *const rule)
}
if (szId > 1 && szStr > 1)
{
- const char cStr = msgStr[szStr - 1];
- const char cId = msgId[szId - 1];
- if (cStr == ' ' && cId != ' ')
+ const char sStr = msgStr[0];
+ const char sId = msgId[0];
+ const char eStr = msgStr[szStr - 1];
+ const char eId = msgId[szId - 1];
+ if (eStr == ' ' && eId != ' ')
rule->print("Useless space at end of translation line.");
std::string name = rule->getFile();
if (findCutLast(name, "po/ar.po") || findCutLast(name, "po/fa.po"))
@@ -71,20 +73,36 @@ static void processMessage(RuleBase *const rule)
if (name.find("po/unused/") != std::string::npos)
return;
- if (cId == '.' ||
- cId == ',' ||
- cId == '!' ||
- cId == '?' ||
- cId == '-' ||
- cId == ':' ||
- cId == ';' ||
- cId == '+' ||
- cId == '|' ||
- cId == ' ')
+ if (eId == '.' ||
+ eId == ',' ||
+ eId == '!' ||
+ eId == '?' ||
+ eId == '-' ||
+ eId == ':' ||
+ eId == ';' ||
+ eId == '+' ||
+ eId == '|' ||
+ eId == '/' ||
+ eId == ' ')
{
- if (cId != cStr)
+ if (eId != eStr)
rule->print("Wrong character at end of translation line.");
}
+ if (sId == '.' ||
+ sId == ',' ||
+ sId == '!' ||
+ sId == '?' ||
+ sId == '-' ||
+ sId == ':' ||
+ sId == ';' ||
+ sId == '+' ||
+ sId == '|' ||
+ sId == '/' ||
+ sId == ' ')
+ {
+ if (sId != sStr)
+ rule->print("Wrong character at start of translation line.");
+ }
if (msgId.find("###") != std::string::npos
&& msgStr.find("###") == std::string::npos)
{
diff --git a/tests/testreport.txt b/tests/testreport.txt
index 4c8dcbf..2a620a7 100644
--- a/tests/testreport.txt
+++ b/tests/testreport.txt
@@ -43,6 +43,7 @@
[testsrc/bad/license6.h:5]: V005: Missing "This file is part of The ManaPlus Client."
[testsrc/bad/packet.cpp:25]: V012: Wrong output packet creation. Must be 'createOutPacket(CMSG...'
[testsrc/bad/uk.po:2257]: V010: Wrong character at end of translation line.
+[testsrc/bad/uk.po:2269]: V010: Wrong character at start of translation line.
[testsrc/bad/uk.po:3712]: V010: Wrong character at end of translation line.
[testsrc/bad/virtual1.cpp:33]: V013: Keywords virtual is useless if used with override or final
[testsrc/bad/virtual1.cpp:36]: V013: Keywords virtual is useless if used with override or final