mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Add some err msg when user ocr fix replacelist is not valid - thx
sialivi :) Related to #5845
This commit is contained in:
parent
b5e102bb0a
commit
dfb4472d24
@ -30,6 +30,8 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
|
||||
private const string ReplaceListFileNamePostFix = "_OCRFixReplaceList.xml";
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public OcrFixReplaceList(string replaceListXmlFileName)
|
||||
{
|
||||
_replaceListXmlFileName = replaceListXmlFileName;
|
||||
@ -994,9 +996,10 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
{
|
||||
doc.Load(_replaceListXmlFileName);
|
||||
}
|
||||
catch
|
||||
catch (Exception exception)
|
||||
{
|
||||
doc.LoadXml(xmlText);
|
||||
ErrorMessage = $"Unable to load ocr replace list {_replaceListXmlFileName}: " + exception.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1018,9 +1021,10 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
{
|
||||
doc.Load(ReplaceListXmlFileNameUser);
|
||||
}
|
||||
catch
|
||||
catch (Exception exception)
|
||||
{
|
||||
doc.LoadXml(xmlText);
|
||||
ErrorMessage = $"Unable to load ocr replace list {ReplaceListXmlFileNameUser}: " + exception.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1105,7 +1109,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
{
|
||||
newNode.Attributes.Append(aFrom);
|
||||
newNode.Attributes.Append(aTo);
|
||||
wholeWordsNode?.AppendChild(newNode);
|
||||
wholeWordsNode.AppendChild(newNode);
|
||||
userDoc.Save(ReplaceListXmlFileNameUser);
|
||||
}
|
||||
|
||||
|
@ -729,6 +729,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_ocrFixEngine?.Dispose();
|
||||
_ocrFixEngineLanguage = threeLetterIsoLanguageName;
|
||||
_ocrFixEngine = new OcrFixEngine(_ocrFixEngineLanguage, null, this);
|
||||
var error = _ocrFixEngine.GetOcrFixReplaceListError();
|
||||
if (error != null)
|
||||
{
|
||||
MessageBox.Show(error);
|
||||
}
|
||||
}
|
||||
|
||||
var fixAction = _language.FixCommonOcrErrors;
|
||||
|
@ -7320,6 +7320,12 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
}
|
||||
|
||||
var tempOcrFixEngine = new OcrFixEngine(threeLetterIsoLanguageName, hunspellName, this, _ocrMethodIndex == _ocrMethodBinaryImageCompare || _ocrMethodIndex == _ocrMethodNocr);
|
||||
var error = _ocrFixEngine.GetOcrFixReplaceListError();
|
||||
if (error != null)
|
||||
{
|
||||
MessageBox.Show(error);
|
||||
}
|
||||
|
||||
if (tempOcrFixEngine.IsDictionaryLoaded)
|
||||
{
|
||||
_ocrFixEngine?.Dispose();
|
||||
|
@ -146,6 +146,18 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
UnknownWordsFound = new List<LogItem>();
|
||||
}
|
||||
|
||||
public string GetOcrFixReplaceListError()
|
||||
{
|
||||
if (_ocrFixReplaceList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var errorMessage = _ocrFixReplaceList.ErrorMessage;
|
||||
_ocrFixReplaceList.ErrorMessage = null;
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
private void LoadSpellingDictionaries(string threeLetterIsoLanguageName, string hunspellName)
|
||||
{
|
||||
string dictionaryFolder = Utilities.DictionaryFolder;
|
||||
|
Loading…
Reference in New Issue
Block a user