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,21 +819,30 @@ 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)
{
string w = node.InnerText.Trim();
if (w.Length > 0 && w != word)
words.Add(w);
foreach (XmlNode node in nodes)
{
string w = node.InnerText.Trim();
if (w.Length > 0 && w != word)
words.Add(w);
}
}
words.Sort();
userWords.DocumentElement.RemoveAll();
foreach (string w in words)
if (userWords.DocumentElement != null)
{
XmlNode node = userWords.CreateElement("word");
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
userWords.DocumentElement.RemoveAll();
foreach (string w in words)
{
XmlNode node = userWords.CreateElement("word");
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
}
}
userWords.Save(userWordsXmlFileName);
}
}
@ -859,22 +860,32 @@ namespace Nikse.SubtitleEdit.Core
userWords.LoadXml("<words />");
var words = new List<string>();
foreach (XmlNode node in userWords.DocumentElement.SelectNodes("word"))
if (userWords.DocumentElement != null)
{
string w = node.InnerText.Trim();
if (w.Length > 0)
words.Add(w);
}
words.Add(word);
words.Sort();
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);
}
}
userWords.DocumentElement.RemoveAll();
foreach (string w in words)
{
XmlNode node = userWords.CreateElement("word");
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
if (!words.Contains(word))
words.Add(word);
words.Sort();
userWords.DocumentElement.RemoveAll();
foreach (string w in words)
{
XmlNode node = userWords.CreateElement("word");
node.InnerText = w;
userWords.DocumentElement.AppendChild(node);
}
}
userWords.Save(userWordsXmlFileName);
}
}
@ -905,11 +916,15 @@ 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)
{
string s = node.InnerText.ToLower();
if (!userWordList.Contains(s))
userWordList.Add(s);
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>