eric7/EricWidgets/EricSpellCheckedTextEdit.py

branch
eric7
changeset 9021
62d6f565f740
parent 8901
adc47f306e51
diff -r 3d87cd80cd45 -r 62d6f565f740 eric7/EricWidgets/EricSpellCheckedTextEdit.py
--- 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