diff --git a/src/ui/Features/Main/MainViewModel.cs b/src/ui/Features/Main/MainViewModel.cs index f05e942c96..dbaa096be7 100644 --- a/src/ui/Features/Main/MainViewModel.cs +++ b/src/ui/Features/Main/MainViewModel.cs @@ -6003,6 +6003,10 @@ private async Task ShowSpeechToTextWhisper() SetSubtitles(_subtitle); SelectAndScrollToRow(0); ShowStatus(string.Format(Se.Language.Main.TranscriptionCompletedWithXLines, _subtitle.Paragraphs.Count)); + + // The subtitle content (and so its language) just changed without a + // file open, so re-evaluate the live spell check dictionary. + SetupLiveSpellCheck(); } else if (result.OkPressed && result.IsBatchMode && result.BatchItems.Count == 1) { @@ -6088,6 +6092,10 @@ private async Task ShowVideoOcr() SetSubtitles(_subtitle); SelectAndScrollToRow(0); ShowStatus(string.Format(Se.Language.Video.VideoOcr.LinesFoundX, _subtitle.Paragraphs.Count)); + + // The subtitle content (and so its language) just changed without a + // file open, so re-evaluate the live spell check dictionary. + SetupLiveSpellCheck(); } } @@ -15464,8 +15472,17 @@ await MessageBox.Show(Window!, Se.Language.General.Error, "This file seems to be private void SetupLiveSpellCheck() { var dictionaryFound = false; - var twoLetterLanguageCode = LanguageAutoDetect.AutoDetectGoogleLanguage(GetUpdateSubtitle()); - var threeLetterLanguageCode = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(twoLetterLanguageCode); + + // Use the detection variant that returns null for an empty or undetectable + // subtitle. The regular variant falls back to English, which armed the + // spell checker with the English dictionary on an empty subtitle at + // startup; content arriving later without a file open (for example a + // transcription in a language with no dictionary installed) was then + // checked against English, underlining every word. + var twoLetterLanguageCode = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(GetUpdateSubtitle()); + var threeLetterLanguageCode = string.IsNullOrEmpty(twoLetterLanguageCode) + ? null + : Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(twoLetterLanguageCode); if (!string.IsNullOrEmpty(threeLetterLanguageCode)) { var spellCheckLanguages = _spellCheckManager.GetDictionaryLanguages(Se.DictionariesFolder);