Make video metadata strings translatable in frontend
In the video page, a small part of the strings was untranslatable, e.g. “Player: ”.
These were part of the video metadata. Now these are localizable.
--- 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;
}
--- a/hedgewars/uVideoRec.pas Thu Mar 15 21:28:10 2018 +0100
+++ b/hedgewars/uVideoRec.pas Fri Mar 16 02:02:27 2018 +0100
@@ -93,7 +93,14 @@
end;
{$IOCHECKS ON}
- // store some description in output file
+ { Store some description in output file.
+ The comment must follow a particular format and must be in English.
+ This will be parsed by the frontend.
+ The frontend will parse lines of this format:
+ Key: Value
+ The key names will be localized in the frontend.
+ If you add a key/value pair, don't forget to add a localization
+ in the frontend! }
desc:= '';
if UserNick <> '' then
desc:= desc + 'Player: ' + UserNick + #10;
--- a/share/hedgewars/Data/Locale/hedgewars_de.ts Thu Mar 15 21:28:10 2018 +0100
+++ b/share/hedgewars/Data/Locale/hedgewars_de.ts Fri Mar 16 02:02:27 2018 +0100
@@ -1049,7 +1049,7 @@
</message>
<message>
<source>Video: %1x%2</source>
- <translation>Video: %1x%2</translation>
+ <translation>Video: %1×%2</translation>
</message>
<message>
<source>%1 fps</source>
@@ -1064,6 +1064,22 @@
<source>%1 FPS</source>
<translation>%1 FPS</translation>
</message>
+ <message>
+ <source>Player: %1</source>
+ <translation>Spieler: %1</translation>
+ </message>
+ <message>
+ <source>Theme: %1</source>
+ <translation>Szenerie: %1</translation>
+ </message>
+ <message>
+ <source>Map: %1</source>
+ <translation>Karte: %1</translation>
+ </message>
+ <message>
+ <source>Record: %1</source>
+ <translation>Aufzeichnung: %1</translation>
+ </message>
</context>
<context>
<name>MainWindow</name>
@@ -4086,11 +4102,11 @@
</message>
<message>
<source>Right shift</source>
- <translation>Rechte Umschalttaste</translation>
+ <translation>Umschalt rechts</translation>
</message>
<message>
<source>Left shift</source>
- <translation>Linke Umschalttaste</translation>
+ <translation>Umschalt links</translation>
</message>
<message>
<source>Right ctrl</source>
--- a/share/hedgewars/Data/Locale/hedgewars_en.ts Thu Mar 15 21:28:10 2018 +0100
+++ b/share/hedgewars/Data/Locale/hedgewars_en.ts Fri Mar 16 02:02:27 2018 +0100
@@ -1014,6 +1014,22 @@
<source>%1 FPS</source>
<translation>%1 FPS</translation>
</message>
+ <message>
+ <source>Player: %1</source>
+ <translation>Player: %1</translation>
+ </message>
+ <message>
+ <source>Theme: %1</source>
+ <translation>Theme: %1</translation>
+ </message>
+ <message>
+ <source>Map: %1</source>
+ <translation>Map: %1</translation>
+ </message>
+ <message>
+ <source>Record: %1</source>
+ <translation>Record: %1</translation>
+ </message>
</context>
<context>
<name>MapModel</name>