Handled an error situation where no spell check dictionary could be found. eric7

Sun, 10 Apr 2022 12:50:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 10 Apr 2022 12:50:49 +0200
branch
eric7
changeset 9021
62d6f565f740
parent 9020
3d87cd80cd45
child 9022
91efc01ae8cb

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):

eric ide

mercurial