Allow for "SE" spell check dictionary file (besides user file)

This commit is contained in:
niksedk 2022-07-19 12:46:59 +02:00
parent 60163124af
commit afb5778c75
3 changed files with 27 additions and 0 deletions

View File

@ -223,6 +223,7 @@ Source: ..\Dictionaries\sr_NoBreakAfterList.xml; DestDir: {userappdata}\Subtit
Source: ..\Dictionaries\da_DK_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
Source: ..\Dictionaries\de_DE_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
Source: ..\Dictionaries\en_US_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
Source: ..\Dictionaries\en_US_se.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion; Components: main
Source: ..\Dictionaries\es_MX_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
Source: ..\Dictionaries\fi_FI_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
Source: ..\Dictionaries\nl_NL_user.xml; DestDir: {userappdata}\Subtitle Edit\Dictionaries; Flags: ignoreversion onlyifdoesntexist; Components: main
@ -359,6 +360,7 @@ Type: files; Name: {app}\Dictionaries\en_US.aff; Check: Is
Type: files; Name: {app}\Dictionaries\en_US.dic; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\en_names.xml; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\en_US_user.xml; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\en_US_se.xml; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\eng_OCRFixReplaceList.xml; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\names.xml; Check: IsUpgrade()
Type: files; Name: {app}\Dictionaries\no_names.xml; Check: IsUpgrade()
@ -678,6 +680,7 @@ begin
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\da_DK_user.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\de_DE_user.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\en_US_user.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\en_US_se.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\es_MX_user.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\fi_FI_user.xml'));
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries\nl_NL_user.xml'));

View File

@ -31,6 +31,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
private readonly HashSet<string> _namesListWithApostrophe = new HashSet<string>();
private readonly HashSet<string> _wordsWithDashesOrPeriods = new HashSet<string>();
private readonly HashSet<string> _userWordList = new HashSet<string>();
private readonly HashSet<string> _seWordList = new HashSet<string>();
private readonly HashSet<string> _userPhraseList = new HashSet<string>();
private readonly string _dictionaryFolder;
private HashSet<string> _skipAllList = new HashSet<string>();
@ -93,6 +94,29 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
}
}
}
if (File.Exists(dictionaryFolder + languageName + "_se.xml"))
{
var userWordDictionary = new XmlDocument();
userWordDictionary.Load(dictionaryFolder + languageName + "_se.xml");
var xmlNodeList = userWordDictionary.DocumentElement?.SelectNodes("word");
if (xmlNodeList != null)
{
foreach (XmlNode node in xmlNodeList)
{
var word = node.InnerText.Trim().ToLowerInvariant();
if (word.Contains(' '))
{
_userPhraseList.Add(word);
}
else
{
_userWordList.Add(word);
}
}
}
}
// Add names/userdic with "." or " " or "-"
foreach (var word in namesMultiWordList)
{