de-duplicate extra comments when adding a message multiple times
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Thu, 1 Aug 2013 14:44:59 +0000 (16:44 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 6 Aug 2013 07:30:42 +0000 (09:30 +0200)
Change-Id: I1ed80166be3cb53f865c083b0a693148b6000731
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/shared/translator.cpp
tests/auto/linguist/lupdate/testdata/good/multiple_locations/main.cpp
tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result

index 43d37f4..f5f4ab7 100644 (file)
@@ -176,9 +176,15 @@ void Translator::extend(const TranslatorMessage &msg, ConversionData &cd)
         emsg.addReferenceUniq(msg.fileName(), msg.lineNumber());
         if (!msg.extraComment().isEmpty()) {
             QString cmt = emsg.extraComment();
-            if (!cmt.isEmpty())
-                cmt.append(QLatin1String("\n----------\n"));
-            cmt.append(msg.extraComment());
+            if (!cmt.isEmpty()) {
+                QStringList cmts = cmt.split(QLatin1String("\n----------\n"));
+                if (!cmts.contains(msg.extraComment())) {
+                    cmts.append(msg.extraComment());
+                    cmt = cmts.join(QLatin1String("\n----------\n"));
+                }
+            } else {
+                cmt = msg.extraComment();
+            }
             emsg.setExtraComment(cmt);
         }
     }
index fa01f9d..b0fd0cb 100644 (file)
@@ -68,3 +68,8 @@ QObject::tr("another message", "here with a lot of noise in the comment so it is
 
 //~ meta too-much-meta
 QObject::tr("another message", "here with a lot of noise in the comment so it is long enough");
+
+
+
+//: commented
+qtTrId("lollipop");
index b0a1717..b3dde96 100644 (file)
@@ -6,6 +6,7 @@
     <message id="lollipop">
         <location filename="main.cpp" line="51"/>
         <location filename="main.cpp" line="56"/>
+        <location filename="main.cpp" line="75"/>
         <source>this is the source text</source>
         <extracomment>commented
 ----------