From 8b18be877893ae448d1947d68ae74a0f006353d2 Mon Sep 17 00:00:00 2001 From: Muaz Date: Thu, 9 Jul 2026 00:27:06 +0300 Subject: [PATCH] Fix live spell check using the English dictionary for other languages Live spell check picks its dictionary by auto detecting the subtitle's language, but the detection helper falls back to English when the subtitle is empty or the language cannot be determined. At startup the setup runs before any file is loaded, so with only the English dictionary installed the spell checker was armed with English. Content that arrives without a file open, such as a speech to text transcription or a video OCR result, never re-evaluated the choice, so an Arabic transcription was spell checked against the English dictionary and every single word was underlined as misspelled. The setup now uses the detection variant that returns null instead of the English fallback (an empty or undetectable subtitle disables live spell check instead of arming it), and the transcription and video OCR result paths re-evaluate the dictionary after inserting their content, the same way opening a file does. This also means a fresh English transcription now gets live spell check enabled, which previously only happened by accident. --- src/ui/Features/Main/MainViewModel.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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);