Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/ui/Features/Main/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);
Expand Down