QTfrontend/util/LibavInteraction.cpp
changeset 13226 4028d7f85233
parent 12239 8db93a3a29dc
child 13286 1fbf2ac1f13e
--- a/QTfrontend/util/LibavInteraction.cpp	Thu Mar 15 21:28:10 2018 +0100
+++ b/QTfrontend/util/LibavInteraction.cpp	Fri Mar 16 02:02:27 2018 +0100
@@ -321,7 +321,36 @@
     }
     AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
     if (pComment)
-        desc += QString("\n") + pComment->value;
+    {
+        // Video comment. We expect a simple key value storage in a particular format
+        // and parse it here so the key names can be localized.
+        desc += QString("\n");
+        QStringList strings = QString(pComment->value).split('\n');
+        QString sPlayer, sTheme, sMap, sRecord;
+        for(int i=0; i < strings.count(); i++)
+        {
+            QString s = strings.at(i);
+            // Original key names are in English, like:
+            //     Key: Value
+            if (s.startsWith("Player: "))
+                sPlayer = QString(s.mid(8));
+            else if (s.startsWith("Theme: "))
+                sTheme = QString(s.mid(7));
+            else if (s.startsWith("Map: "))
+                sMap = QString(s.mid(5));
+            else if (s.startsWith("Record: "))
+                sRecord = QString(s.mid(8));
+        }
+        if(!sPlayer.isNull())
+            desc += QString(tr("Player: %1")).arg(sPlayer) + "\n";
+        if(!sTheme.isNull())
+            desc += QString(tr("Theme: %1")).arg(sTheme) + "\n";
+        if(!sMap.isNull())
+            desc += QString(tr("Map: %1")).arg(sMap) + "\n";
+        if(!sRecord.isNull())
+            //: As in ‘recording’
+            desc += QString(tr("Record: %1")).arg(sRecord);
+    }
     avformat_close_input(&pContext);
     return desc;
 }