complain about missing sources in id-based messages
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Fri, 2 Aug 2013 17:02:55 +0000 (19:02 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 7 Aug 2013 16:05:16 +0000 (18:05 +0200)
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 <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/lupdate/main.cpp
tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt
tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result

index 25486a0..9846ea5 100644 (file)
@@ -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<Translator> aliens;
     foreach (const QString &fileName, alienFiles) {
         ConversionData cd;
index d4ebe49..dfbd4b7 100644 (file)
@@ -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\.
index 99fe293..fecfa9a 100644 (file)
@@ -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");
index 806f56f..3202f9d 100644 (file)
@@ -2,6 +2,14 @@
 <!DOCTYPE TS>
 <TS version="2.0">
 <context>
+    <name></name>
+    <message id="no_source">
+        <location filename="main.cpp" line="132"/>
+        <source></source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>NameSpace::ToBeUsed</name>
     <message>
         <location filename="main.cpp" line="113"/>