From: Oswald Buddenhagen Date: Fri, 2 Aug 2013 17:02:55 +0000 (+0200) Subject: complain about missing sources in id-based messages X-Git-Tag: accepted/tizen/20131212.181521~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b06dc951f535ce137a26d2062f4b074ea1d72441;p=platform%2Fupstream%2Fqttools.git complain about missing sources in id-based messages i considered making this optional on the basis that the source strings may be assigned externally, but in that scenario lupdate wouldn't be used to start with. Task-number: QTBUG-11843 Change-Id: I3f09db902462b8e94f7a134f6fe950562b300307 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index 25486a0..9846ea5 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -287,6 +287,13 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil const QString &sourceLanguage, const QString &targetLanguage, UpdateOptions options, bool *fail) { + for (int i = 0; i < fetchedTor.messageCount(); i++) { + const TranslatorMessage &msg = fetchedTor.constMessage(i); + if (!msg.id().isEmpty() && msg.sourceText().isEmpty()) + printErr(LU::tr("lupdate warning: Message with id '%1' has no source.\n") + .arg(msg.id())); + } + QList aliens; foreach (const QString &fileName, alienFiles) { ConversionData cd; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt index d4ebe49..dfbd4b7 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt @@ -5,3 +5,4 @@ .*/lupdate/testdata/good/parsecpp2/main.cpp:120: //% cannot be used with tr\(\) / QT_TR_NOOP\(\)\. Ignoring .*/lupdate/testdata/good/parsecpp2/main.cpp:123: //% cannot be used with translate\(\) / QT_TRANSLATE_NOOP\(\)\. Ignoring .*/lupdate/testdata/good/parsecpp2/main.cpp:126: Discarding unconsumed meta data +lupdate warning: Message with id 'no_source' has no source\. diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp index 99fe293..fecfa9a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp @@ -125,3 +125,8 @@ QApplication::translate("QObject", "Hello World"); //% "Baz" clear = me; QObject::tr("Hello World"); + + + +// QTBUG-11843: complain about missing source in id-based messages +qtTrId("no_source"); diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result index 806f56f..3202f9d 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result @@ -2,6 +2,14 @@ + + + + + + + + NameSpace::ToBeUsed