From cce2dab67a0f4ea6996587d8d57f679a5e0286e6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 3 Jan 2016 18:20:50 +0300 Subject: Add support for check firs char in translations (po files). --- src/rules/po.cpp | 46 ++++++++++++++++++++++++++++++++-------------- tests/testreport.txt | 1 + 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 -- cgit v1.2.3-60-g2f50