From 2cf8661b9790946713711fdf0cf24450053c8b37 Mon Sep 17 00:00:00 2001 From: Daniel Kamil Kozar Date: Fri, 6 Mar 2020 00:20:05 +0100 Subject: [PATCH] Fix translated strings appearing in the metafile (#233) --- tsMuxerGUI/translations/tsmuxergui_en.ts | 81 +++++++++++------------ tsMuxerGUI/translations/tsmuxergui_ru.ts | 83 +++++++++++------------- tsMuxerGUI/tsmuxerwindow.cpp | 55 ++++++++++------ tsMuxerGUI/tsmuxerwindow.h | 3 +- 4 files changed, 114 insertions(+), 108 deletions(-) diff --git a/tsMuxerGUI/translations/tsmuxergui_en.ts b/tsMuxerGUI/translations/tsmuxergui_en.ts index 0212ff9..5821d97 100644 --- a/tsMuxerGUI/translations/tsmuxergui_en.ts +++ b/tsMuxerGUI/translations/tsmuxergui_en.ts @@ -760,7 +760,7 @@ - + Demux @@ -771,7 +771,7 @@ - + File name @@ -787,7 +787,7 @@ - + Sta&rt muxing @@ -797,15 +797,10 @@ - + All supported media files (*.aac *.mpv *.mpa *.avc *.mvc *.264 *.h264 *.ac3 *.dts *.ts *.m2ts *.mts *.ssif *.mpg *.mpeg *.vob *.evo *.mkv *.mka *.mks *.mp4 *.m4a *.m4v *.mov *.sup *.wav *.w64 *.pcm *.m1v *.m2v *.vc1 *.hevc *.hvc *.265 *.h265 *.mpls *.mpl *.srt);;AC3/E-AC3 (*.ac3 *.ddp);;AAC (advanced audio coding) (*.aac);;AVC/MVC/H.264 elementary stream (*.avc *.mvc *.264 *.h264);;HEVC (High Efficiency Video Codec) (*.hevc *.hvc *.265 *.h265);;Digital Theater System (*.dts);;Mpeg video elementary stream (*.mpv *.m1v *.m2v);;Mpeg audio elementary stream (*.mpa);;Transport Stream (*.ts);;BDAV Transport Stream (*.m2ts *.mts *.ssif);;Program Stream (*.mpg *.mpeg *.vob *.evo);;Matroska audio/video files (*.mkv *.mka *.mks);;MP4 audio/video files (*.mp4 *.m4a *.m4v);;Quick time audio/video files (*.mov);;Blu-ray play list (*.mpls *.mpl);;Blu-ray PGS subtitles (*.sup);;Text subtitles (*.srt);;WAVE - Uncompressed PCM audio (*.wav *.w64);;RAW LPCM Stream (*.pcm);;All files (*.*) - - - tsMuxeR project file (*.meta);;All files (*.*) - - Transport stream (*.ts);;all files (*.*) @@ -822,156 +817,156 @@ - + Not supported - - + + Unsupported format - + Can't detect stream type. File name: "%1" - + Add media file - + File already exists - + File "%1" already exists - + Unsupported format or all tracks are not recognized. File name: "%1" - - Some tracks not recognized. This tracks was ignored. File name: "%1" + + Track %1 was not recognized and ignored. File name: "%2" - + Mux - + tsMuxeR error - + tsMuxeR not found! - + Can't execute tsMuxeR! - - + + No track selected - + Append media file - + Invalid file extension - + Appended file must have same file extension. - + Sta&rt demuxing - + Folder - + Select file for muxing - - + + Invalid file name - + The output file "%1" has invalid extension. Please, change file extension to ".m2ts" - + The output file "%1" has invalid extension. Please, change file extension to ".iso" - + file Used in expressions "Overwrite existing %1" and "The output %1 already exists". - + directory - + Overwrite existing %1? - + The output %1 "%2" already exists. Do you want to overwrite it? - + Muxing in progress - + Demuxing in progress - + Can't create temporary meta file - + Can't create temporary meta file "%1" diff --git a/tsMuxerGUI/translations/tsmuxergui_ru.ts b/tsMuxerGUI/translations/tsmuxergui_ru.ts index b25d039..3882258 100644 --- a/tsMuxerGUI/translations/tsmuxergui_ru.ts +++ b/tsMuxerGUI/translations/tsmuxergui_ru.ts @@ -760,7 +760,7 @@ - + Demux Демукс @@ -771,7 +771,7 @@ - + File name Имя Файла @@ -787,7 +787,7 @@ - + Sta&rt muxing Ста&рт муксинга @@ -797,15 +797,10 @@ Сохранить проект - + All supported media files (*.aac *.mpv *.mpa *.avc *.mvc *.264 *.h264 *.ac3 *.dts *.ts *.m2ts *.mts *.ssif *.mpg *.mpeg *.vob *.evo *.mkv *.mka *.mks *.mp4 *.m4a *.m4v *.mov *.sup *.wav *.w64 *.pcm *.m1v *.m2v *.vc1 *.hevc *.hvc *.265 *.h265 *.mpls *.mpl *.srt);;AC3/E-AC3 (*.ac3 *.ddp);;AAC (advanced audio coding) (*.aac);;AVC/MVC/H.264 elementary stream (*.avc *.mvc *.264 *.h264);;HEVC (High Efficiency Video Codec) (*.hevc *.hvc *.265 *.h265);;Digital Theater System (*.dts);;Mpeg video elementary stream (*.mpv *.m1v *.m2v);;Mpeg audio elementary stream (*.mpa);;Transport Stream (*.ts);;BDAV Transport Stream (*.m2ts *.mts *.ssif);;Program Stream (*.mpg *.mpeg *.vob *.evo);;Matroska audio/video files (*.mkv *.mka *.mks);;MP4 audio/video files (*.mp4 *.m4a *.m4v);;Quick time audio/video files (*.mov);;Blu-ray play list (*.mpls *.mpl);;Blu-ray PGS subtitles (*.sup);;Text subtitles (*.srt);;WAVE - Uncompressed PCM audio (*.wav *.w64);;RAW LPCM Stream (*.pcm);;All files (*.*) - - - tsMuxeR project file (*.meta);;All files (*.*) - - Transport stream (*.ts);;all files (*.*) @@ -822,157 +817,157 @@ - + Not supported Не поддерживается - - + + Unsupported format Неподдерживаемый формат - + Can't detect stream type. File name: "%1" Не определён тип потока. Имя файла: "%1" - + Add media file Добавить медиафайл - + File already exists Файл уже есть - + File "%1" already exists Файл "%1" уже есть - + Unsupported format or all tracks are not recognized. File name: "%1" Неподдерживаемый формат или все дорожки не распознаны. Имя файла: "%1" - - Some tracks not recognized. This tracks was ignored. File name: "%1" - Некоторые дорожки не распознаны. Эта дорожка была проигнорирована. Имя файла: "%1" + + Track %1 was not recognized and ignored. File name: "%2" + Дорожка %1 не распознана и проигнорирована. Имя файла: "%2" - + Mux Создать - + tsMuxeR error Ошибка tsMuxeR - + tsMuxeR not found! tsMuxeR не найден! - + Can't execute tsMuxeR! Не возможно запустить tsMuxeR! - - + + No track selected Не выбрана дорожка - + Append media file Присоединить медиафайл - + Invalid file extension Неверное расширение файла - + Appended file must have same file extension. Присоединяемый файл должен иметь тоже самое расширение файла. - + Sta&rt demuxing Ста&rт демуксинга - + Folder Папка - + Select file for muxing Выберите файл для муксинга - - + + Invalid file name Неверное имя файла - + The output file "%1" has invalid extension. Please, change file extension to ".m2ts" Выходной файл "%1" имеет недопустимое расширение. Пожалуйста, измените расширение файла на ".m2ts" - + The output file "%1" has invalid extension. Please, change file extension to ".iso" Выходной файл "%1" имеет недопустимое расширение. Пожалуйста, измените расширение файла на ".iso" - + file Used in expressions "Overwrite existing %1" and "The output %1 already exists". Используется в фразах "Переписать существующий %1" и "Файл %1 уже существует". файл - + directory каталог - + Overwrite existing %1? Переписать существующий %1? - + The output %1 "%2" already exists. Do you want to overwrite it? Результат %1 "%2" уже есть. Хотите его перезаписать? - + Muxing in progress Выполняется муксинг - + Demuxing in progress Выполняется демуксинг - + Can't create temporary meta file Не возможно создать временный файл проекта - + Can't create temporary meta file "%1" Не возможно создать временный файл проекта "%1" diff --git a/tsMuxerGUI/tsmuxerwindow.cpp b/tsMuxerGUI/tsmuxerwindow.cpp index dbefbe4..cc20e7f 100644 --- a/tsMuxerGUI/tsmuxerwindow.cpp +++ b/tsMuxerGUI/tsmuxerwindow.cpp @@ -20,6 +20,8 @@ #include "muxForm.h" #include "ui_tsmuxerwindow.h" +namespace +{ QString fileDialogFilter() { return TsMuxerWindow::tr( @@ -45,8 +47,6 @@ RAW LPCM Stream (*.pcm);;\ All files (*.*)"); } -QString saveMetaFilter() { return TsMuxerWindow::tr("tsMuxeR project file (*.meta);;All files (*.*)"); } - QString TI_DEFAULT_TAB_NAME() { return TsMuxerWindow::tr("General track options"); } QString TI_DEMUX_TAB_NAME() { return TsMuxerWindow::tr("Demux options"); } @@ -69,8 +69,6 @@ enum FileCustomData static const QString FILE_JOIN_PREFIX(" ++ "); -namespace -{ bool doubleCompare(double a, double b) { return qAbs(a - b) < 1e-6; } QString closeDirPath(const QString &src) @@ -280,6 +278,7 @@ TsMuxerWindow::TsMuxerWindow() m_3dMode(false) { ui->setupUi(this); + setUiMetaItemsData(); qApp->installTranslator(&qtCoreTranslator); qApp->installTranslator(&tsMuxerTranslator); initLanguageComboBox(ui->languageSelectComboBox); @@ -639,9 +638,8 @@ QtvCodecInfo *TsMuxerWindow::getCurrentCodec() return getCodecInfo(row); } -void TsMuxerWindow::onVideoComboBoxChanged(int index) +void TsMuxerWindow::onVideoComboBoxChanged(int) { - Q_UNUSED(index); if (disableUpdatesCnt) return; QtvCodecInfo *codecInfo = getCurrentCodec(); @@ -649,7 +647,7 @@ void TsMuxerWindow::onVideoComboBoxChanged(int index) return; codecInfo->fpsText = ui->comboBoxFPS->itemText(ui->comboBoxFPS->currentIndex()); codecInfo->levelText = ui->comboBoxLevel->itemText(ui->comboBoxLevel->currentIndex()); - codecInfo->arText = ui->comboBoxAR->itemText(ui->comboBoxAR->currentIndex()); + codecInfo->arText = ui->comboBoxAR->currentData().toString(); updateMetaLines(); } @@ -791,6 +789,27 @@ void TsMuxerWindow::postMoveComboBoxUpdate(QComboBox *comboBox, const QVariant & comboBox->setCurrentIndex(idx); } +void TsMuxerWindow::setUiMetaItemsData() +{ + // unfortunately, the .ui files don't allow the user to specify "item data" for combo boxes, which is the most + // convenient way to associate some extra data that's not displayed in the UI in a combo box item without having + // to resort to some kind of external containers which need to be kept synchronised. + // as some of the combo boxes are taken as input for the meta file, it would end up having translated strings in it + // if a non-English translation is active, and thus being invalid. item data for these UI items should always + // contain the valid metafile tokens, as they are the actual things incorporated into the metafile content. + ui->comboBoxAR->setItemData(0, QString()); + ui->comboBoxAR->setItemData(1, "1:1"); + ui->comboBoxAR->setItemData(2, "4:3"); + ui->comboBoxAR->setItemData(3, "16:9"); + ui->comboBoxAR->setItemData(4, "2.21:1"); + ui->comboBoxMeasure->setItemData(0, "KB"); + ui->comboBoxMeasure->setItemData(1, "KiB"); + ui->comboBoxMeasure->setItemData(2, "MB"); + ui->comboBoxMeasure->setItemData(3, "MiB"); + ui->comboBoxMeasure->setItemData(4, "GB"); + ui->comboBoxMeasure->setItemData(5, "GiB"); +} + void TsMuxerWindow::onAudioSubtitlesParamsChanged() { if (disableUpdatesCnt) @@ -986,13 +1005,13 @@ void TsMuxerWindow::trackLVItemSelectionChanged() ui->tabWidgetTracks->addTab(ui->demuxLpcmOptions, TI_DEMUX_TAB_NAME()); if (codecInfo->displayName == "DTS-HD") - ui->dtsDwnConvert->setText("Downconvert DTS-HD to DTS"); + ui->dtsDwnConvert->setText(tr("Downconvert DTS-HD to DTS")); else if (codecInfo->displayName == "TRUE-HD") - ui->dtsDwnConvert->setText("Downconvert TRUE-HD to AC3"); + ui->dtsDwnConvert->setText(tr("Downconvert TRUE-HD to AC3")); else if (codecInfo->displayName == "E-AC3 (DD+)") - ui->dtsDwnConvert->setText("Downconvert E-AC3 to AC3"); + ui->dtsDwnConvert->setText(tr("Downconvert E-AC3 to AC3")); else - ui->dtsDwnConvert->setText("Downconvert HD audio"); + ui->dtsDwnConvert->setText(tr("Downconvert HD audio")); ui->dtsDwnConvert->setEnabled(codecInfo->displayName == "DTS-HD" || codecInfo->displayName == "TRUE-HD" || codecInfo->displayName == "E-AC3 (DD+)"); ui->secondaryCheckBox->setEnabled(codecInfo->descr.contains("(DTS Express)") || @@ -1122,9 +1141,8 @@ void TsMuxerWindow::continueAddFile() msgBox.setStandardButtons(QMessageBox::Ok); if (codecList.size() == 0) { - msgBox.setText(tr("Unsupported format or all tracks are not " - "recognized. File name: \"%1\"") - .arg(newFileName)); + msgBox.setText( + tr("Unsupported format or all tracks are not recognized. File name: \"%1\"").arg(newFileName)); msgBox.exec(); disableUpdatesCnt--; return; @@ -1133,9 +1151,8 @@ void TsMuxerWindow::continueAddFile() { if (firstWarn) { - msgBox.setText(tr("Some tracks not recognized. This tracks was " - "ignored. File name: \"%1\"") - .arg(newFileName)); + msgBox.setText( + tr("Track %1 was not recognized and ignored. File name: \"%2\"").arg(i).arg(newFileName)); msgBox.exec(); firstWarn = false; } @@ -1597,7 +1614,7 @@ QString TsMuxerWindow::getMuxOpts() if (ui->splitByDuration->isChecked()) rez += QString(" --split-duration=") + ui->spinEditSplitDuration->text(); if (ui->splitBySize->isChecked()) - rez += QString(" --split-size=") + ui->editSplitSize->text() + ui->comboBoxMeasure->currentText(); + rez += QString(" --split-size=") + ui->editSplitSize->text() + ui->comboBoxMeasure->currentData().toString(); int startCut = qTimeToMsec(ui->cutStartTimeEdit->time()); int endCut = qTimeToMsec(ui->cutEndTimeEdit->time()); @@ -1797,7 +1814,7 @@ QString TsMuxerWindow::getVideoMetaInfo(QtvCodecInfo *codecInfo) rezStr += QString(", ") + "contSPS"; if (codecInfo->delPulldown == 1) rezStr += QString(", ") + "delPulldown"; - if (codecInfo->arText != "Not change" && !codecInfo->arText.isEmpty()) + if (!codecInfo->arText.isEmpty()) rezStr += QString(", ") + "ar=" + codecInfo->arText; if (codecInfo->isSecondary) diff --git a/tsMuxerGUI/tsmuxerwindow.h b/tsMuxerGUI/tsmuxerwindow.h index 557134e..92c13e8 100644 --- a/tsMuxerGUI/tsmuxerwindow.h +++ b/tsMuxerGUI/tsmuxerwindow.h @@ -146,9 +146,8 @@ class TsMuxerWindow : public QWidget void updateTracksComboBox(QComboBox*); void moveTrackInDefaultComboBox(int oldIndex, int newIndex); void postMoveComboBoxUpdate(QComboBox*, const QVariant& preMoveIndex, int oldIndex, int newIndex); + void setUiMetaItemsData(); - // QTemporaryFile* tempFile; - // QString tempFileName; QString metaName; Ui::TsMuxerWindow* ui; QFileDialog* openFileDialog;