# HG changeset patch # User Wuzzy # Date 1521162147 -3600 # Node ID 4028d7f852339948df98109b58b94b08c2c7413d # Parent d6364e31f9c9b5cdf14e2c475d8b547aae8aa7ad 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. diff -r d6364e31f9c9 -r 4028d7f85233 QTfrontend/util/LibavInteraction.cpp --- 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; } diff -r d6364e31f9c9 -r 4028d7f85233 hedgewars/uVideoRec.pas --- 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; diff -r d6364e31f9c9 -r 4028d7f85233 share/hedgewars/Data/Locale/hedgewars_de.ts --- 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 @@ Video: %1x%2 - Video: %1x%2 + Video: %1×%2 %1 fps @@ -1064,6 +1064,22 @@ %1 FPS %1 FPS + + Player: %1 + Spieler: %1 + + + Theme: %1 + Szenerie: %1 + + + Map: %1 + Karte: %1 + + + Record: %1 + Aufzeichnung: %1 + MainWindow @@ -4086,11 +4102,11 @@ Right shift - Rechte Umschalttaste + Umschalt rechts Left shift - Linke Umschalttaste + Umschalt links Right ctrl diff -r d6364e31f9c9 -r 4028d7f85233 share/hedgewars/Data/Locale/hedgewars_en.ts --- 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 @@ %1 FPS %1 FPS + + Player: %1 + Player: %1 + + + Theme: %1 + Theme: %1 + + + Map: %1 + Map: %1 + + + Record: %1 + Record: %1 + MapModel