don't ignore changes to meta data when updating translation units
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Thu, 1 Aug 2013 15:48:58 +0000 (17:48 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 6 Aug 2013 07:30:47 +0000 (09:30 +0200)
Task-number: QTBUG-18890
Change-Id: Iceb466105d5fae56da0e2d26cb245fa610fed865
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/lupdate/merge.cpp
tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result

index bf77013..103e2b2 100644 (file)
@@ -351,6 +351,7 @@ Translator merge(
             if (mvi >= 0)
                 m.setComment(virginTor.constMessage(mvi).comment());
         } else {
+            TranslatorMessage::ExtraData extras;
             const TranslatorMessage *mv;
             int mvi = virginTor.find(m);
             if (mvi < 0) {
@@ -377,6 +378,8 @@ Translator merge(
                     }
                     // It is just slightly modified, assume that it is the same string
 
+                    extras = mv->extras();
+
                     // Mark it as unfinished. (Since the source text
                     // was changed it might require re-translating...)
                     newType = TranslatorMessage::Unfinished;
@@ -386,6 +389,7 @@ Translator merge(
                 }
             } else {
                 mv = &virginTor.message(mvi);
+                extras = mv->extras();
                 if (!mv->id().isEmpty()
                     && (mv->context() != m.context()
                         || mv->sourceText() != m.sourceText()
@@ -399,10 +403,8 @@ Translator merge(
                         m.setOldSourceText(m.sourceText());
                         m.setSourceText(mv->sourceText());
                         const QString &oldpluralsource = m.extra(QLatin1String("po-msgid_plural"));
-                        if (!oldpluralsource.isEmpty()) {
-                            m.setExtra(QLatin1String("po-old_msgid_plural"), oldpluralsource);
-                            m.unsetExtra(QLatin1String("po-msgid_plural"));
-                        }
+                        if (!oldpluralsource.isEmpty())
+                            extras.insert(QLatin1String("po-old_msgid_plural"), oldpluralsource);
                     }
                 } else {
                     switch (m.type()) {
@@ -432,6 +434,7 @@ Translator merge(
                 // why not use operator=()? Because it overwrites e.g. userData.
                 m.setReferences(mv->allReferences());
                 m.setPlural(mv->isPlural());
+                m.setExtras(extras);
                 m.setExtraComment(mv->extraComment());
                 m.setId(mv->id());
             }
index 78ab97b..ae4ac75 100644 (file)
@@ -65,7 +65,7 @@ void FindDialog::reset()
     tr("%n item(s)", "merge from a finished singular form to an unfinished plural form", 4);
 
 
-
+    //~ meta matter
     //% "Hello"
     qtTrId("xx_hello");
 
index 379cce4..6adc539 100644 (file)
@@ -6,6 +6,7 @@
         <location filename="finddialog.cpp" line="70"/>
         <source>Hello</source>
         <translation>Hallo</translation>
+        <extra-meta>something really clever</extra-meta>
     </message>
     <message id="xx_world">
         <location filename="finddialog.cpp" line="73"/>
index de43266..aa25d42 100644 (file)
@@ -7,6 +7,7 @@
         <location filename="finddialog.cpp" line="70"/>
         <source>Hello</source>
         <translation>Hallo</translation>
+        <extra-meta>matter</extra-meta>
     </message>
     <message id="xx_world">
         <location filename="finddialog.cpp" line="73"/>