diff --git a/README.md b/README.md index 8a58806f..6b8a73e8 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,16 @@ Most shortcuts are labelled with the corresponding dropdown menu entry. ## 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-appdirs -* python3-lxml -* python3-enchant +* `python3-pyqt5` for the GUI +* `python3-appdirs` for locating the system's config folder +* `python3-lxml` for writing project files + +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 ``` diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 0c8e8d76..0900cf11 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -520,7 +520,7 @@ class GuiMain(QMainWindow): def closeMain(self): - if self.mainConf.showGUI: + if self.mainConf.showGUI and self.hasProject: msgBox = QMessageBox() msgRes = msgBox.question( self, "Exit", "Do you want to save changes and exit?" diff --git a/nw/tools/spellenchant.py b/nw/tools/spellenchant.py index afa6a3cb..61c9a012 100644 --- a/nw/tools/spellenchant.py +++ b/nw/tools/spellenchant.py @@ -14,6 +14,12 @@ import logging import enchant import nw +try: + import pycountry + hasPyCountry = True +except: + hasPyCountry = False + from nw.tools.spellcheck import NWSpellCheck logger = logging.getLogger(__name__) @@ -30,7 +36,7 @@ class NWSpellEnchant(NWSpellCheck): self.theDict = enchant.Dict(theLang) else: 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 def checkWord(self, theWord): @@ -46,7 +52,20 @@ class NWSpellEnchant(NWSpellCheck): def listDictionaries(self): retList = [] 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 # END Class NWSpellEnchant diff --git a/requirements.txt b/requirements.txt index 039ca559..a83517dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ pyqt5 appdirs lxml pyenchant +pycountry diff --git a/sample/sampleNovel/meta/sessionInfo.log b/sample/sampleNovel/meta/sessionInfo.log index 1defe611..3a0f392b 100644 --- a/sample/sampleNovel/meta/sessionInfo.log +++ b/sample/sampleNovel/meta/sessionInfo.log @@ -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: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 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 diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index b7bbbada..8f8715df 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -80,7 +80,7 @@ 736 137 6 - 738 + 473 New File