Videos frontend page: Locale-aware text formatting
authorWuzzy <Wuzzy2@mail.ru>
Tue, 27 Mar 2018 19:59:12 +0200
changeset 13286 1fbf2ac1f13e
parent 13285 fd1017c85dd4
child 13287 29055da6a6cd
Videos frontend page: Locale-aware text formatting
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/util/LibavInteraction.cpp
share/hedgewars/Data/Locale/hedgewars_de.ts
share/hedgewars/Data/Locale/hedgewars_en.ts
--- a/QTfrontend/ui/page/pagevideos.cpp	Tue Mar 27 13:45:58 2018 -0400
+++ b/QTfrontend/ui/page/pagevideos.cpp	Tue Mar 27 19:59:12 2018 +0200
@@ -234,19 +234,8 @@
 // get file size as string
 static QString FileSizeStr(const QString & path)
 {
-    quint64 size = QFileInfo(path).size();
-
-    quint64 KiB = 1024;
-    quint64 MiB = 1024*KiB;
-    quint64 GiB = 1024*MiB;
-    QString sizeStr;
-    if (size >= GiB)
-        return QString("%1 GiB").arg(QString::number(float(size)/GiB, 'f', 2));
-    if (size >= MiB)
-        return QString("%1 MiB").arg(QString::number(float(size)/MiB, 'f', 2));
-     if (size >= KiB)
-        return QString("%1 KiB").arg(QString::number(float(size)/KiB, 'f', 2));
-    return PageVideos::tr("%1 bytes", "", size).arg(QString::number(size));
+    qint64 size = QFileInfo(path).size();
+    return QLocale().formattedDataSize(size);
 }
 
 // set file size in file list in specified row
@@ -319,7 +308,8 @@
 {
     QProgressBar * progressBar = (QProgressBar*)filesTable->cellWidget(row, vcProgress);
     progressBar->setValue(value*10000);
-    progressBar->setFormat(QString("%1%").arg(value*100, 0, 'f', 2));
+    //: Video encoding progress. %1 = number
+    progressBar->setFormat(QString(tr("%1%")).arg(QLocale().toString(value*100, 'f', 2)));
     item->progress = value;
 }
 
@@ -694,14 +684,17 @@
     {
         VideoItem * item = nameItem(i);
         QString process;
-        if (!item->ready())
-            process = tr("encoding");
-        else
+        if (item->ready())
             continue;
         float progress = 100*item->progress;
         if (progress > 99.99)
             progress = 99.99; // displaying 100% may be confusing
-        list += item->name + " (" + QString::number(progress, 'f', 2) + "% - " + process + ")\n";
+        //: Video encoding list entry. %1 = file name, %2 = percent complete, %3 = video operation type (e.g. “encoding”)
+        list += QString(tr("%1 (%2%) - %3"))
+            .arg(item->name)
+            .arg(QLocale().toString(progress, 'f', 2))
+            .arg(tr("encoding"))
+            + "\n";
     }
     return list;
 }
--- a/QTfrontend/util/LibavInteraction.cpp	Tue Mar 27 13:45:58 2018 -0400
+++ b/QTfrontend/util/LibavInteraction.cpp	Tue Mar 27 19:59:12 2018 +0200
@@ -302,21 +302,30 @@
         if (!pCodec)
             continue;
 
+
+        AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
+        QString decoderName = pDecoder ? pDecoder->name : tr("unknown");
         if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
         {
-            desc += QString(tr("Video: %1x%2")).arg(pCodec->width).arg(pCodec->height) + ", ";
             if (pStream->avg_frame_rate.den)
             {
                 float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den;
-                desc += QString(tr("%1 FPS")).arg(fps, 0, 'f', 2) + ", ";
+                //: Video metadata. %1 = video width, %2 = video height, %3 = frames per second = %4 = decoder name
+                desc += QString(tr("Video: %1x%2, %3 FPS, %4")).arg(pCodec->width).arg(pCodec->height).arg(QLocale().toString(fps, 'f', 2)).arg(decoderName);
+            }
+            else
+            {
+                //: Video metadata. %1 = video width, %2 = video height, %3 = decoder name
+                desc += QString(tr("Video: %1x%2, %3")).arg(pCodec->width).arg(pCodec->height).arg(decoderName);
             }
         }
         else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO)
+        {
             desc += tr("Audio: ");
+            desc += decoderName;
+        }
         else
             continue;
-        AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
-        desc += pDecoder? pDecoder->name : tr("unknown");
         desc += "\n";
     }
     AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
--- a/share/hedgewars/Data/Locale/hedgewars_de.ts	Tue Mar 27 13:45:58 2018 -0400
+++ b/share/hedgewars/Data/Locale/hedgewars_de.ts	Tue Mar 27 19:59:12 2018 +0200
@@ -1049,7 +1049,7 @@
     </message>
     <message>
         <source>Video: %1x%2</source>
-        <translation>Video: %1×%2</translation>
+        <translation type="vanished">Video: %1×%2</translation>
     </message>
     <message>
         <source>%1 fps</source>
@@ -1062,7 +1062,7 @@
     </message>
     <message>
         <source>%1 FPS</source>
-        <translation>%1 FPS</translation>
+        <translation type="vanished">%1 FPS</translation>
     </message>
     <message>
         <source>Player: %1</source>
@@ -1080,6 +1080,16 @@
         <source>Record: %1</source>
         <translation>Aufzeichnung: %1</translation>
     </message>
+    <message>
+        <source>Video: %1x%2, %3 FPS, %4</source>
+        <extracomment>Video metadata. %1 = video width, %2 = video height, %3 = frames per second = %4 = decoder name</extracomment>
+        <translation>Video: %1×%2, %3 FPS, %4</translation>
+    </message>
+    <message>
+        <source>Video: %1x%2, %3</source>
+        <extracomment>Video metadata. %1 = video width, %2 = video height, %3 = decoder name</extracomment>
+        <translation>Video: %1×%2, %3</translation>
+    </message>
 </context>
 <context>
     <name>MainWindow</name>
@@ -2241,7 +2251,7 @@
     </message>
     <message numerus="yes">
         <source>%1 bytes</source>
-        <translation>
+        <translation type="vanished">
             <numerusform>%1 Byte</numerusform>
             <numerusform>%1 Bytes</numerusform>
         </translation>
@@ -2276,6 +2286,21 @@
         <source>Size: %1</source>
         <translation>Größe: %1</translation>
     </message>
+    <message>
+        <source>%1%</source>
+        <extracomment>Video encoding progress. %1 = number</extracomment>
+        <translation>%1%</translation>
+    </message>
+    <message>
+        <source>%1 (%2%) - %3)</source>
+        <extracomment>Video encoding list entry. %1 = file name, %2 = percent complete, %3 = video operation type (e.g. “encoding”)</extracomment>
+        <translation type="vanished">%1 (%2%) – %3</translation>
+    </message>
+    <message>
+        <source>%1 (%2%) - %3</source>
+        <extracomment>Video encoding list entry. %1 = file name, %2 = percent complete, %3 = video operation type (e.g. “encoding”)</extracomment>
+        <translation>%1 (%2%) – %3</translation>
+    </message>
 </context>
 <context>
     <name>QAction</name>
--- a/share/hedgewars/Data/Locale/hedgewars_en.ts	Tue Mar 27 13:45:58 2018 -0400
+++ b/share/hedgewars/Data/Locale/hedgewars_en.ts	Tue Mar 27 19:59:12 2018 +0200
@@ -1003,7 +1003,7 @@
     </message>
     <message>
         <source>Video: %1x%2</source>
-        <translation>Video: %1×%2</translation>
+        <translation type="vanished">Video: %1×%2</translation>
     </message>
     <message>
         <source>Duration: %1min %2s</source>
@@ -1012,7 +1012,7 @@
     </message>
     <message>
         <source>%1 FPS</source>
-        <translation>%1 FPS</translation>
+        <translation type="vanished">%1 FPS</translation>
     </message>
     <message>
         <source>Player: %1</source>
@@ -1030,6 +1030,16 @@
         <source>Record: %1</source>
         <translation>Record: %1</translation>
     </message>
+    <message>
+        <source>Video: %1x%2, %3 FPS, %4</source>
+        <extracomment>Video metadata. %1 = video width, %2 = video height, %3 = frames per second = %4 = decoder name</extracomment>
+        <translation>Video: %1×%2, %3 FPS, %4</translation>
+    </message>
+    <message>
+        <source>Video: %1x%2, %3</source>
+        <extracomment>Video metadata. %1 = video width, %2 = video height, %3 = decoder name</extracomment>
+        <translation>Video: %1×%2, %3</translation>
+    </message>
 </context>
 <context>
     <name>MapModel</name>
@@ -2129,7 +2139,7 @@
     </message>
     <message numerus="yes">
         <source>%1 bytes</source>
-        <translation>
+        <translation type="vanished">
             <numerusform>%1 byte</numerusform>
             <numerusform>%1 bytes</numerusform>
         </translation>
@@ -2154,6 +2164,21 @@
         <source>Size: %1</source>
         <translation>Size: %1</translation>
     </message>
+    <message>
+        <source>%1%</source>
+        <extracomment>Video encoding progress. %1 = number</extracomment>
+        <translation>%1%</translation>
+    </message>
+    <message>
+        <source>%1 (%2%) - %3)</source>
+        <extracomment>Video encoding list entry. %1 = file name, %2 = percent complete, %3 = video operation type (e.g. “encoding”)</extracomment>
+        <translation type="vanished">%1 (%2%) - %3</translation>
+    </message>
+    <message>
+        <source>%1 (%2%) - %3</source>
+        <extracomment>Video encoding list entry. %1 = file name, %2 = percent complete, %3 = video operation type (e.g. “encoding”)</extracomment>
+        <translation>%1 (%2%)—%3</translation>
+    </message>
 </context>
 <context>
     <name>QAction</name>