Sun, 10 Apr 2022 12:50:49 +0200
Handled an error situation where no spell check dictionary could be found.
eric7/EricWidgets/EricSpellCheckedTextEdit.py | file | annotate | diff | comparison | revisions |
--- a/eric7/EricWidgets/EricSpellCheckedTextEdit.py Sun Apr 10 12:50:18 2022 +0200 +++ b/eric7/EricWidgets/EricSpellCheckedTextEdit.py Sun Apr 10 12:50:49 2022 +0200 @@ -410,9 +410,18 @@ @param pel file name of the personal exclude list @type str """ - self.__highlighter.setDict( - enchant.DictWithPWL(language, pwl, pel) - ) + try: + spellDict = enchant.DictWithPWL(language, pwl, pel) + except DictNotFoundError: + try: + # Use English dictionary if a dictionary for the given + # language is not available. + spellDict = enchant.DictWithPWL("en", pwl, pel) + except DictNotFoundError: + # Still no dictionary could be found. Forget about spell + # checking. + spellDict = None + self.__highlighter.setDict(spellDict) @classmethod def setDefaultLanguage(cls, language, pwl=None, pel=None):