Finish the word list dialog and make it possible to reload the user dictionary with pyenchant
This commit is contained in:
+11
-1
@@ -123,6 +123,7 @@ class NWSpellCheck():
|
||||
if len(theLine) > 0 and theLine not in self.projDict:
|
||||
self.projDict.append(theLine)
|
||||
logger.debug("Project word list contains %d words" % len(self.projDict))
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load project word list")
|
||||
nw.logException()
|
||||
@@ -141,6 +142,7 @@ class NWSpellEnchant(NWSpellCheck):
|
||||
def __init__(self):
|
||||
NWSpellCheck.__init__(self)
|
||||
logger.debug("Enchant spell checking activated")
|
||||
self.theBroker = None
|
||||
return
|
||||
|
||||
def setLanguage(self, theLang, projectDict=None):
|
||||
@@ -150,9 +152,15 @@ class NWSpellEnchant(NWSpellCheck):
|
||||
"""
|
||||
try:
|
||||
import enchant
|
||||
self.theDict = enchant.Dict(theLang)
|
||||
if self.theBroker is not None:
|
||||
logger.verbose("Deleting old pyenchant Broker")
|
||||
del self.theBroker
|
||||
|
||||
self.theBroker = enchant.Broker()
|
||||
self.theDict = self.theBroker.request_dict(theLang)
|
||||
self.spellLanguage = theLang
|
||||
logger.debug("Enchant spell checking for language %s loaded" % theLang)
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load enchant spell checking for language %s" % theLang)
|
||||
self.theDict = NWSpellEnchantDummy()
|
||||
@@ -258,9 +266,11 @@ class NWSpellSimple(NWSpellCheck):
|
||||
if len(theLine) == 0 or theLine.startswith("#"):
|
||||
continue
|
||||
self.WORDS.append(theLine.strip().lower())
|
||||
|
||||
logger.debug("Spell check word list for language %s loaded" % theLang)
|
||||
logger.debug("Word list contains %d words" % len(self.WORDS))
|
||||
self.spellLanguage = theLang
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to load spell check word list for language %s" % theLang)
|
||||
nw.logException()
|
||||
|
||||
Reference in New Issue
Block a user