Completed the pyenchant wrapper class
This commit is contained in:
@@ -80,12 +80,16 @@ Most shortcuts are labelled with the corresponding dropdown menu entry.
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
For the apt package manager, the following Python3 packages are needed.
|
For the apt package manager, the following Python3 packages are needed:
|
||||||
|
|
||||||
* python3-pyqt5
|
* `python3-pyqt5` for the GUI
|
||||||
* python3-appdirs
|
* `python3-appdirs` for locating the system's config folder
|
||||||
* python3-lxml
|
* `python3-lxml` for writing project files
|
||||||
* python3-enchant
|
|
||||||
|
These are optional, but recommended:
|
||||||
|
|
||||||
|
* `python3-enchant` for spell checking
|
||||||
|
* `python3-pycountry` for translating language codes to language names
|
||||||
|
|
||||||
Alternatively, the packages can be installed with `pip` by running
|
Alternatively, the packages can be installed with `pip` by running
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -520,7 +520,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
def closeMain(self):
|
def closeMain(self):
|
||||||
|
|
||||||
if self.mainConf.showGUI:
|
if self.mainConf.showGUI and self.hasProject:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgRes = msgBox.question(
|
msgRes = msgBox.question(
|
||||||
self, "Exit", "Do you want to save changes and exit?"
|
self, "Exit", "Do you want to save changes and exit?"
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ import logging
|
|||||||
import enchant
|
import enchant
|
||||||
import nw
|
import nw
|
||||||
|
|
||||||
|
try:
|
||||||
|
import pycountry
|
||||||
|
hasPyCountry = True
|
||||||
|
except:
|
||||||
|
hasPyCountry = False
|
||||||
|
|
||||||
from nw.tools.spellcheck import NWSpellCheck
|
from nw.tools.spellcheck import NWSpellCheck
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -30,7 +36,7 @@ class NWSpellEnchant(NWSpellCheck):
|
|||||||
self.theDict = enchant.Dict(theLang)
|
self.theDict = enchant.Dict(theLang)
|
||||||
else:
|
else:
|
||||||
self.theDict = enchant.DictWithPWL(theLang, projectDict)
|
self.theDict = enchant.DictWithPWL(theLang, projectDict)
|
||||||
logger.debug("Enchant spell checking for %s loaded" % theLang)
|
logger.debug("Enchant spell checking for language %s loaded" % theLang)
|
||||||
return
|
return
|
||||||
|
|
||||||
def checkWord(self, theWord):
|
def checkWord(self, theWord):
|
||||||
@@ -46,7 +52,20 @@ class NWSpellEnchant(NWSpellCheck):
|
|||||||
def listDictionaries(self):
|
def listDictionaries(self):
|
||||||
retList = []
|
retList = []
|
||||||
for spTag, spProvider in enchant.list_dicts():
|
for spTag, spProvider in enchant.list_dicts():
|
||||||
retList.append((spTag, "%s [%s]" % (spTag, spProvider.name)))
|
if hasPyCountry:
|
||||||
|
spList = []
|
||||||
|
try:
|
||||||
|
langObj = pycountry.languages.get(alpha_2 = spTag[:2])
|
||||||
|
spList.append(langObj.name)
|
||||||
|
except:
|
||||||
|
spList.append(spTag[:2])
|
||||||
|
if len(spTag) > 3:
|
||||||
|
spList.append("(%s)" % spTag[3:])
|
||||||
|
spList.append("[%s]" % spProvider.name)
|
||||||
|
spName = " ".join(spList)
|
||||||
|
else:
|
||||||
|
spName = "%s [%s]" % (spTag, spProvider.name)
|
||||||
|
retList.append((spTag, spName))
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
# END Class NWSpellEnchant
|
# END Class NWSpellEnchant
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ pyqt5
|
|||||||
appdirs
|
appdirs
|
||||||
lxml
|
lxml
|
||||||
pyenchant
|
pyenchant
|
||||||
|
pycountry
|
||||||
|
|||||||
@@ -210,3 +210,10 @@ Start: 2019-06-10 21:48:51 End: 2019-06-10 21:49:07 Words: 0
|
|||||||
Start: 2019-06-10 22:17:58 End: 2019-06-10 22:18:44 Words: 0
|
Start: 2019-06-10 22:17:58 End: 2019-06-10 22:18:44 Words: 0
|
||||||
Start: 2019-06-10 22:46:35 End: 2019-06-10 22:49:34 Words: 0
|
Start: 2019-06-10 22:46:35 End: 2019-06-10 22:49:34 Words: 0
|
||||||
Start: 2019-06-11 14:44:55 End: 2019-06-11 14:53:47 Words: 0
|
Start: 2019-06-11 14:44:55 End: 2019-06-11 14:53:47 Words: 0
|
||||||
|
Start: 2019-06-11 19:26:07 End: 2019-06-11 19:26:18 Words: 0
|
||||||
|
Start: 2019-06-11 19:26:44 End: 2019-06-11 19:26:50 Words: 0
|
||||||
|
Start: 2019-06-11 19:30:30 End: 2019-06-11 19:30:37 Words: 0
|
||||||
|
Start: 2019-06-11 19:31:16 End: 2019-06-11 19:31:50 Words: 0
|
||||||
|
Start: 2019-06-11 20:04:39 End: 2019-06-11 20:05:00 Words: 0
|
||||||
|
Start: 2019-06-11 20:05:04 End: 2019-06-11 20:08:49 Words: 0
|
||||||
|
Start: 2019-06-11 20:20:52 End: 2019-06-11 20:21:18 Words: 0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<novelWriterXML appVersion="0.1.5" fileVersion="1.0" timeStamp="2019-06-11 14:46:19">
|
<novelWriterXML appVersion="0.1.5" fileVersion="1.0" timeStamp="2019-06-11 20:21:18">
|
||||||
<project>
|
<project>
|
||||||
<name>Sample Project</name>
|
<name>Sample Project</name>
|
||||||
<title>Sample Project</title>
|
<title>Sample Project</title>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<charCount>736</charCount>
|
<charCount>736</charCount>
|
||||||
<wordCount>137</wordCount>
|
<wordCount>137</wordCount>
|
||||||
<paraCount>6</paraCount>
|
<paraCount>6</paraCount>
|
||||||
<cursorPos>738</cursorPos>
|
<cursorPos>473</cursorPos>
|
||||||
</item>
|
</item>
|
||||||
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
|
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
|
||||||
<name>New File</name>
|
<name>New File</name>
|
||||||
|
|||||||
Reference in New Issue
Block a user