More work on #6058

This commit is contained in:
niksedk 2022-12-05 20:51:10 +01:00
parent 8fe4943eda
commit 1304bccf75
3 changed files with 29 additions and 3 deletions

View File

@ -2205,6 +2205,7 @@ can edit in same subtitle file (collaboration)</Information>
<AutoBackupEveryFiveMinutes>Every 5th minute</AutoBackupEveryFiveMinutes>
<AutoBackupEveryFifteenMinutes>Every 15th minute</AutoBackupEveryFifteenMinutes>
<AutoBackupDeleteAfter>Delete after</AutoBackupDeleteAfter>
<TranslationAutoSuffix>Translation auto suffix</TranslationAutoSuffix>
<AutoBackupDeleteAfterOneMonth>1 month</AutoBackupDeleteAfterOneMonth>
<AutoBackupDeleteAfterXMonths>{0} months</AutoBackupDeleteAfterXMonths>
<CheckForUpdates>Check for updates</CheckForUpdates>

View File

@ -4811,20 +4811,42 @@ namespace Nikse.SubtitleEdit.Forms
saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory;
}
var suffix = string.Empty;
if (_subtitleOriginal != null && !string.IsNullOrEmpty(Configuration.Settings.General.TranslationAutoSuffixDefault))
{
if (Configuration.Settings.General.TranslationAutoSuffixDefault.StartsWith('<'))
{
var translationLangauge = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(_subtitle);
if (!string.IsNullOrEmpty(translationLangauge))
{
suffix = "." + translationLangauge;
}
else
{
var originalLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleOriginal);
suffix = "." + GenericTranslate.EvaluateDefaultTargetLanguageCode(originalLanguage);
}
}
else
{
suffix = Configuration.Settings.General.TranslationAutoSuffixDefault;
}
}
if (!string.IsNullOrWhiteSpace(_fileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("file", StringComparison.OrdinalIgnoreCase))
{
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName);
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName) + suffix;
saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName);
}
else if (!string.IsNullOrEmpty(_videoFileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("video", StringComparison.OrdinalIgnoreCase))
{
if (_converted && !string.IsNullOrEmpty(_fileName) && !File.Exists(_fileName))
{
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName);
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName) + suffix;
}
else
{
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_videoFileName);
saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_videoFileName) + suffix;
}
saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_videoFileName);

View File

@ -5962,6 +5962,9 @@ namespace Nikse.SubtitleEdit.Logic
case "Settings/AutoBackupDeleteAfter":
language.Settings.AutoBackupDeleteAfter = reader.Value;
break;
case "Settings/TranslationAutoSuffix":
language.Settings.TranslationAutoSuffix = reader.Value;
break;
case "Settings/AutoBackupDeleteAfterOneMonth":
language.Settings.AutoBackupDeleteAfterOneMonth = reader.Value;
break;