mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Merge pull request #7233 from ivandrofly/feature/refact-fix
Update/Fixes AdvancedTextBox
This commit is contained in:
commit
7efaff923e
@ -591,6 +591,19 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsDictionaryAvailable(string language)
|
||||
{
|
||||
foreach (var downloadedDictionary in Utilities.GetDictionaryLanguagesCultureNeutral())
|
||||
{
|
||||
if (downloadedDictionary.Contains($"[{language}]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task InitializeLiveSpellCheck(Subtitle subtitle, int lineNumber)
|
||||
{
|
||||
if (lineNumber < 0)
|
||||
@ -601,21 +614,9 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
if (_spellCheckWordLists is null && _hunspell is null)
|
||||
{
|
||||
var detectedLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle, 300);
|
||||
var downloadedDictionaries = Utilities.GetDictionaryLanguagesCultureNeutral();
|
||||
var isDictionaryAvailable = false;
|
||||
foreach (var downloadedDictionary in downloadedDictionaries)
|
||||
IsDictionaryDownloaded = false;
|
||||
if (IsDictionaryAvailable(detectedLanguage))
|
||||
{
|
||||
if (downloadedDictionary.Contains($"[{detectedLanguage}]"))
|
||||
{
|
||||
isDictionaryAvailable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isDictionaryAvailable)
|
||||
{
|
||||
IsDictionaryDownloaded = true;
|
||||
|
||||
var languageName = LanguageAutoDetect.AutoDetectLanguageName(string.Empty, subtitle);
|
||||
if (languageName.Split('_', '-')[0] != detectedLanguage)
|
||||
{
|
||||
@ -623,22 +624,18 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
|
||||
await LoadDictionariesAsync(languageName);
|
||||
IsDictionaryDownloaded = true;
|
||||
IsSpellCheckerInitialized = true;
|
||||
IsSpellCheckRequested = true;
|
||||
TextChangedHighlight(this, EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
IsDictionaryDownloaded = false;
|
||||
}
|
||||
|
||||
LanguageChanged = true;
|
||||
CurrentLanguage = detectedLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadDictionariesAsync(string languageName) =>
|
||||
await Task.Run(() => LoadDictionaries(languageName));
|
||||
private Task LoadDictionariesAsync(string languageName) => new Task(() => LoadDictionaries(languageName));
|
||||
|
||||
private void LoadDictionaries(string languageName)
|
||||
{
|
||||
@ -848,7 +845,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CurrentLanguage == "en " && (currentWordText.Equals("a", StringComparison.OrdinalIgnoreCase) || currentWordText == "I"))
|
||||
if (CurrentLanguage == "en" && (currentWordText.Equals("a", StringComparison.OrdinalIgnoreCase) || currentWordText == "I"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user