This commit is contained in:
Nikolaj Olsson 2018-03-16 09:31:53 +01:00
parent d936b4f39c
commit 5b90eb1f2f
3 changed files with 55 additions and 39 deletions

View File

@ -1,6 +1,4 @@
using Nikse.SubtitleEdit.Core.ContainerFormats;
using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska;
using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4;
using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using System;
using System.Collections.Generic;
@ -660,13 +658,7 @@ namespace Nikse.SubtitleEdit.Core
return s;
}
public static string DictionaryFolder
{
get
{
return Configuration.DictionariesDirectory;
}
}
public static string DictionaryFolder => Configuration.DictionariesDirectory;
public static List<string> GetDictionaryLanguages()
{
@ -676,7 +668,7 @@ namespace Nikse.SubtitleEdit.Core
foreach (string dic in Directory.GetFiles(DictionaryFolder, "*.dic"))
{
string name = Path.GetFileNameWithoutExtension(dic);
if (name != null && !name.StartsWith("hyph", StringComparison.Ordinal))
if (!name.StartsWith("hyph", StringComparison.Ordinal))
{
try
{
@ -827,14 +819,21 @@ namespace Nikse.SubtitleEdit.Core
userWords.LoadXml("<words />");
var words = new List<string>();
foreach (XmlNode node in userWords.DocumentElement.SelectNodes("word"))
var nodes = userWords.DocumentElement?.SelectNodes("word");
if (nodes != null)
{
foreach (XmlNode node in nodes)
{
string w = node.InnerText.Trim();
if (w.Length > 0 && w != word)
words.Add(w);
}
}
words.Sort();
if (userWords.DocumentElement != null)
{
userWords.DocumentElement.RemoveAll();
foreach (string w in words)
{
@ -842,6 +841,8 @@ namespace Nikse.SubtitleEdit.Core
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
}
}
userWords.Save(userWordsXmlFileName);
}
}
@ -859,12 +860,20 @@ namespace Nikse.SubtitleEdit.Core
userWords.LoadXml("<words />");
var words = new List<string>();
foreach (XmlNode node in userWords.DocumentElement.SelectNodes("word"))
if (userWords.DocumentElement != null)
{
var nodes = userWords.DocumentElement.SelectNodes("word");
if (nodes != null)
{
foreach (XmlNode node in nodes)
{
string w = node.InnerText.Trim();
if (w.Length > 0)
words.Add(w);
}
}
if (!words.Contains(word))
words.Add(word);
words.Sort();
@ -875,6 +884,8 @@ namespace Nikse.SubtitleEdit.Core
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
}
}
userWords.Save(userWordsXmlFileName);
}
}
@ -905,13 +916,17 @@ namespace Nikse.SubtitleEdit.Core
if (File.Exists(userWordListXmlFileName))
{
userWordDictionary.Load(userWordListXmlFileName);
foreach (XmlNode node in userWordDictionary.DocumentElement.SelectNodes("word"))
var nodes = userWordDictionary.DocumentElement?.SelectNodes("word");
if (nodes != null)
{
foreach (XmlNode node in nodes)
{
string s = node.InnerText.ToLower();
if (!userWordList.Contains(s))
userWordList.Add(s);
}
}
}
return userWordListXmlFileName;
}

View File

@ -1230,8 +1230,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
case OcrSpellCheck.Action.AddToUserDictionary:
if (_userWordListXmlFileName != null)
{
_userWordList.Add(_spellCheck.Word.Trim().ToLower());
Utilities.AddToUserDictionary(_spellCheck.Word.Trim().ToLower(), _fiveLetterWordListLanguageName);
_userWordList.Add(_spellCheck.Word.Trim().ToLower());
}
result.Word = _spellCheck.Word;
result.Fixed = true;
@ -1245,6 +1245,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
try
{
string s = _spellCheck.Word.Trim();
_nameListObj?.Add(s);
if (s.Contains(' '))
_nameMultiWordList.Add(s);
else
@ -1259,7 +1260,6 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
_nameListWithApostrophe.Add(s + "'");
}
}
_nameListObj?.Add(s);
}
catch
{

View File

@ -11,6 +11,7 @@
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSA/@EntryIndexedValue">SSA</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>