From 034e9bfb6f37dca22614a67450d424cd277f26d7 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 8 Nov 2024 18:16:34 +0100 Subject: [PATCH] Remember iTunes TTML language code (or auto-detect) - thx Andreas :) --- src/libse/Settings/SubtitleSettings.cs | 1 + src/libse/SubtitleFormats/ItunesTimedText.cs | 7 ++++++- src/ui/Forms/TimedTextPropertiesItunes.cs | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libse/Settings/SubtitleSettings.cs b/src/libse/Settings/SubtitleSettings.cs index 902da0970..08f6882cc 100644 --- a/src/libse/Settings/SubtitleSettings.cs +++ b/src/libse/Settings/SubtitleSettings.cs @@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Core.Settings public string TimedTextItunesBottomExtent { get; set; } public string TimedTextItunesTimeCodeFormat { get; set; } public string TimedTextItunesStyleAttribute { get; set; } + public string TimedTextItunesLanguage { get; set; } public string TimedTextImsc11TimeCodeFormat { get; set; } public string TimedTextImsc11FileExtension { get; set; } diff --git a/src/libse/SubtitleFormats/ItunesTimedText.cs b/src/libse/SubtitleFormats/ItunesTimedText.cs index b999af722..6c4201962 100644 --- a/src/libse/SubtitleFormats/ItunesTimedText.cs +++ b/src/libse/SubtitleFormats/ItunesTimedText.cs @@ -108,7 +108,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats dropMode = "dropNTSC"; } - const string language = "en-US"; + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + if (!string.IsNullOrEmpty(Configuration.Settings.SubtitleSettings.TimedTextItunesLanguage)) + { + language = Configuration.Settings.SubtitleSettings.TimedTextItunesLanguage; + } + var xmlStructure = "" + Environment.NewLine + "" + Environment.NewLine + " " + Environment.NewLine + diff --git a/src/ui/Forms/TimedTextPropertiesItunes.cs b/src/ui/Forms/TimedTextPropertiesItunes.cs index e1e75aa41..78833643f 100644 --- a/src/ui/Forms/TimedTextPropertiesItunes.cs +++ b/src/ui/Forms/TimedTextPropertiesItunes.cs @@ -66,6 +66,11 @@ namespace Nikse.SubtitleEdit.Forms comboBoxLanguage.Text = attr.InnerText; } + if (!string.IsNullOrEmpty(Configuration.Settings.SubtitleSettings.TimedTextItunesLanguage)) + { + comboBoxLanguage.Text = Configuration.Settings.SubtitleSettings.TimedTextItunesLanguage; + } + attr = _xml.DocumentElement.Attributes["ttp:timeBase"]; if (attr != null) { @@ -322,6 +327,8 @@ namespace Nikse.SubtitleEdit.Forms _subtitle.Header = _xml.OuterXml; + Configuration.Settings.SubtitleSettings.TimedTextItunesLanguage = comboBoxLanguage.Text; + Configuration.Settings.SubtitleSettings.TimedTextItunesTimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString(); Configuration.Settings.SubtitleSettings.TimedText10FileExtension = comboBoxFileExtensions.SelectedItem.ToString();