From a366356b9ea4c092927dbc330d06b79a1f6bc210 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 26 Oct 2019 21:03:22 +0100 Subject: [PATCH] WinGui: Fix some errors in translation. Placeholders for autoname are not translatable currently. These are now back to english. (Something to look at for the next version). Also minor improvements to the AutoNameHelper to handle "{source}" as an available option and generally make it more flexible. #2373 --- win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs | 52 +++++++++---------- .../Properties/Resources.Designer.cs | 6 +-- .../HandBrakeWPF/Properties/Resources.de.resx | 38 +++++++------- .../HandBrakeWPF/Properties/Resources.es.resx | 38 +++++++------- .../HandBrakeWPF/Properties/Resources.fr.resx | 42 +++++++-------- .../HandBrakeWPF/Properties/Resources.ko.resx | 42 +++++++-------- win/CS/HandBrakeWPF/Properties/Resources.resx | 6 +-- .../HandBrakeWPF/Properties/Resources.ru.resx | 38 +++++++------- .../HandBrakeWPF/Properties/Resources.tr.resx | 38 +++++++------- .../HandBrakeWPF/Properties/Resources.zh.resx | 38 +++++++------- 10 files changed, 167 insertions(+), 171 deletions(-) diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs index ff76aee70..b1033c8f9 100644 --- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs @@ -12,13 +12,16 @@ namespace HandBrakeWPF.Helpers using System; using System.IO; using System.Linq; + using System.Reflection; using Caliburn.Micro; using HandBrake.Interop.Interop.Model.Encoding; + using HandBrakeWPF.Converters; using HandBrakeWPF.Extensions; using HandBrakeWPF.Model.Options; + using HandBrakeWPF.Properties; using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Services.Presets.Model; @@ -111,8 +114,10 @@ namespace HandBrakeWPF.Helpers * Generate the full path and filename */ string destinationFilename = GenerateDestinationFileName(task, userSettingService, sourceName, dvdTitle, combinedChapterTag, createDate, createTime); - string autoNamePath = GetAutonamePath(userSettingService, task, destinationFilename); - autoNamePath = CheckAndHandleFilenameCollisions(autoNamePath, destinationFilename, task, userSettingService); + string autoNamePath = GetAutonamePath(userSettingService, task, sourceName); + string finalPath = Path.Combine(autoNamePath, destinationFilename); + + autoNamePath = CheckAndHandleFilenameCollisions(finalPath, destinationFilename, task, userSettingService); return autoNamePath; } @@ -204,7 +209,7 @@ namespace HandBrakeWPF.Helpers return destinationFilename; } - private static string GetAutonamePath(IUserSettingService userSettingService, EncodeTask task, string destinationFilename) + private static string GetAutonamePath(IUserSettingService userSettingService, EncodeTask task, string sourceName) { string autoNamePath = string.Empty; @@ -216,11 +221,20 @@ namespace HandBrakeWPF.Helpers string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source); - string requestedPath = Path.Combine(directory, savedPath); + autoNamePath = Path.Combine(directory, savedPath); + } + else + { + autoNamePath = userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim(); + } - autoNamePath = Path.Combine(requestedPath, destinationFilename); + if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source}") && !string.IsNullOrEmpty(task.Source)) + { + sourceName = Path.GetInvalidPathChars().Aggregate(sourceName, (current, character) => current.Replace(character.ToString(), string.Empty)); + autoNamePath = autoNamePath.Replace("{source}", sourceName); } - else if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !string.IsNullOrEmpty(task.Source)) + + if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !string.IsNullOrEmpty(task.Source)) { // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source. string path = Path.GetDirectoryName(task.Source); @@ -229,30 +243,16 @@ namespace HandBrakeWPF.Helpers string[] filesArray = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string sourceFolder = filesArray[filesArray.Length - 1]; - autoNamePath = Path.Combine(userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder), destinationFilename); + autoNamePath = userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder); } } - else if (!task.Destination.Contains(Path.DirectorySeparatorChar.ToString())) - { - // Third case: If the destination box doesn't already contain a path, make one. - if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim() != string.Empty && - userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim() != "Click 'Browse' to set the default location") - { - autoNamePath = Path.Combine(userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath), destinationFilename); - } - else - { - // ...otherwise, output to the source directory - autoNamePath = null; - } - } - else + + // Fallback to the users "Videos" folder. + if (string.IsNullOrEmpty(autoNamePath) || autoNamePath == Resources.OptionsView_SetDefaultLocationOutputFIle) { - // Otherwise, use the path that is already there. - // Use the path and change the file extension to match the previous destination - autoNamePath = Path.Combine(Path.GetDirectoryName(task.Destination), destinationFilename); + autoNamePath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); } - + return autoNamePath; } diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index e6b1887b1..ccf4a541d 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -2858,9 +2858,7 @@ namespace HandBrakeWPF.Properties { } /// - /// Looks up a localized string similar to Available additional Options: {source_path} or {source_folder_name} - /// - ///Not both at the same time!. + /// Looks up a localized string similar to Available additional Options: {source_path} or {source_folder_name} or {source}. /// public static string Options_DefaultPathAdditionalParams { get { @@ -3493,7 +3491,7 @@ namespace HandBrakeWPF.Properties { } /// - /// Looks up a localized string similar to Available Options: {source_path} {source_folder_name} (Not both at the same time!). + /// Looks up a localized string similar to Available Options: {source_path} {source_folder_name} {source}. /// public static string OptionsView_PathOptions { get { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.de.resx b/win/CS/HandBrakeWPF/Properties/Resources.de.resx index b4ef9a318..6d78f734b 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.de.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.de.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1897,7 +1897,7 @@ verbleibende Zeit: {5:hh\:mm\:ss}, vergangen: {6:hh\:mm\:ss} {7} Nicht-Echtzeit Optionen: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (Diese werden nur geändert, wenn eine neue Quelle gescannt, Titel oder Kapitel geändert werden) - Verfügbare Optionen: {source_path} oder {source_folder_name} (Nicht beide zur selben Zeit!) + Verfügbare Optionen: {source_path} {source_folder_name} {source} Fragen um Datei zu überschreiben @@ -2159,4 +2159,4 @@ Falls unterstützt, wird jede benutzerdefinierte Voreinstellung übernommen. Wöchentlich - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.es.resx b/win/CS/HandBrakeWPF/Properties/Resources.es.resx index 3216dc748..ea663d777 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.es.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.es.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1911,7 +1911,7 @@ Actualice los controladores de GPU para cualquier gráfico integrado y discreto Opciones no en vivo: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (Estos solo cambian si escanea una nueva fuente, cambia el título o los capítulos) - Optiones Disponibles: {source_path} {source_folder_name} (¡No ambos al mismo tiempo!) + Optiones Disponibles: {source_path} {source_folder_name} {source} Preguntar si se sobreescribe el archivo @@ -2049,4 +2049,4 @@ Cuando se admita, se habrán importado los ajustes preestablecidos de usuario. Preview Rotation and Flip - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.fr.resx b/win/CS/HandBrakeWPF/Properties/Resources.fr.resx index 063724153..7dfde0752 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.fr.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.fr.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1908,11 +1908,11 @@ Temps Restant : {5:hh\:mm\:ss}, Écoulé : {6:hh\:mm\:ss} {7} Le moteur d'HandBrake n'a pas pu s'initialiser. Cela est souvent dû à des pilotes GPU obsolètes.\n Veuillez mettre à jour les pilotes GPU de toutes les cartes graphiques intégrés et dédiées de votre système. - Options mises à jour en direct : {source} {titre} {chapitres} -Options en différé : {date} {heure} {date-de-création} {heure-de-création} {qualité} {débit} (Ceux-ci changent uniquement quand vous scannez une nouvelle source, changez de titre ou de chapitres) + Options mises à jour en direct : {source} {title} {chapters} +Options en différé : {date} {time} {creation-date} {creation-time} {quality} {bitrate} (Ceux-ci changent uniquement quand vous scannez une nouvelle source, changez de titre ou de chapitres) - Options disponibles : {chemin_source} {nom_dossier_source} (Un seul à la fois !) + Options disponibles : {source_path} {source_folder_name} {source} Demander pour écraser le fichier @@ -2174,4 +2174,4 @@ Là où pris en charge, tous les préréglages utilisateur auront été importé Hebdomadaire - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.ko.resx b/win/CS/HandBrakeWPF/Properties/Resources.ko.resx index fa620e844..f851f93dc 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.ko.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.ko.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1903,11 +1903,11 @@ FPS: {3:000.0}, 평균 FPS: {4:000.0} HandBrake 엔진이 초기화하는데 실패하였습니다. GPU 드라이브가 오래되었을 경우 종종 발생하는 문제입니다.\n 시스템에 탑재된 개별 그래픽에 대한 GPU 드라이브를 업데이트하십시오. - Live 업데이트 옵션: {자료} {제목} {챕터} -Non-Live 옵션: {날짜} {시간} {생성-날짜} {생성-시간} {해상도} {비트 전송속도} ( + Live 업데이트 옵션: {source} {title} {chapters} +Non-Live 옵션: {date} {time} {creation-date} {creation-time} {quality} {bitrate} - 이용 가능한 옵션: {자료_경로} {자료_폴더_이름} (동시에 이용 불가능합니다!) + 이용 가능한 옵션: {source_path} {source_folder_name} {source} 파일 덮어쓰기 요청 @@ -2169,4 +2169,4 @@ Non-Live 옵션: {날짜} {시간} {생성-날짜} {생성-시간} {해상도} { 매 주 - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 576f10799..eb271f567 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -339,9 +339,7 @@ Live Update Options: {source} {title} {chapters} Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (These only change if you scan a new source, change title or chapters) - Available additional Options: {source_path} or {source_folder_name} - -Not both at the same time! + Available additional Options: {source_path} or {source_folder_name} or {source} You cannot encode to a file with the same path and filename as the source file. Please update the destination filename so that it does not match the source file. @@ -1912,7 +1910,7 @@ Time Remaining: {5:hh\:mm\:ss}, Elapsed: {6:hh\:mm\:ss} {7} Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (These only change if you scan a new source, change title or chapters) - Available Options: {source_path} {source_folder_name} (Not both at the same time!) + Available Options: {source_path} {source_folder_name} {source} Ask to overwrite file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.ru.resx b/win/CS/HandBrakeWPF/Properties/Resources.ru.resx index 15d8d9e71..1b79cefc7 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.ru.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.ru.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1911,7 +1911,7 @@ FPS: {3:000.0}, Сред FPS: {4:000.0} Опции неживого обновления: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (Они меняются только если вы сканируете новый источник, изменяете заголовок или главы) - Доступные опции: {source_path} {source_folder_name} (Не обе одновременно!) + Доступные опции: {source_path} {source_folder_name} {source} Спрашивать при перезаписи файла @@ -2173,4 +2173,4 @@ FPS: {3:000.0}, Сред FPS: {4:000.0} Еженедельно - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.tr.resx b/win/CS/HandBrakeWPF/Properties/Resources.tr.resx index d40e97fe4..05b48b11c 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.tr.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.tr.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1912,7 +1912,7 @@ Kalan Süre: {5:hh\:mm\:ss}, Geçen: {6:hh\:mm\:ss} {7} Canlı Olmayan Seçenekler: {date} {time} {creation-date} {creation-time} {quality} {bitrate} (Bunlar yalnızca yeni bir kaynak tararsanız, başlığı veya bölümleri değiştirirseniz değişir) - Kullanılabilir Seçenekler: {source_path} {source_folder_name} (Her ikisi de aynı anda değil!) + Kullanılabilir Seçenekler: {source_path} {source_folder_name} {source} Dosyanın üzerine yazılmasını isteyin @@ -2174,4 +2174,4 @@ Desteklendiğinde, herhangi bir kullanıcı ön ayarı içe aktarılmış olacak Haftalık - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.zh.resx b/win/CS/HandBrakeWPF/Properties/Resources.zh.resx index 8844d7ffe..66b54e409 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.zh.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.zh.resx @@ -1,4 +1,4 @@ - + - + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1901,7 +1901,7 @@ FPS: {3:000.0}, 平均FPS: {4:000.0} 非实时更新选项:{date} {time} {creation-date} {creation-time} {quality} {bitrate} (只有扫描新源、更改标题或章节时才会更改) - 可选的附加项:{source_path} {source_folder_name} (不能同时使用) + 可选的附加项:{source_path} {source_folder_name} {source} 询问是否覆盖文件 @@ -2163,4 +2163,4 @@ FPS: {3:000.0}, 平均FPS: {4:000.0} 每周 - + \ No newline at end of file -- 2.40.0