From 8aa2401134a1b22a40eeeefc0565fb89289ef9a1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 16 Feb 2021 22:42:18 +0100 Subject: [PATCH] Make sure the project translation map is loaded correctly --- nw/core/project.py | 24 +++++++++++++++--------- nw/gui/preferences.py | 4 ++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/nw/core/project.py b/nw/core/project.py index 2b75227d..5fd1be72 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -607,10 +607,7 @@ class NWProject(): self.theParent.setStatus("Opened Project: %s" % self.projName) self._scanProjectFolder() - if self.projLang is None: - self._loadProjectLocalisation(self.mainConf.guiLang) - else: - self._loadProjectLocalisation(self.projLang) + self.loadProjectLocalisation(self.projLang) self.currWCount = self.lastWCount self.projOpened = time() @@ -1016,6 +1013,7 @@ class NWProject(): theLang = checkString(theLang, None, True) if self.projLang != theLang: self.projLang = theLang + self.loadProjectLocalisation(theLang) self.setProjectChanged(True) return True @@ -1211,17 +1209,21 @@ class NWProject(): theValue = str(theWord) return self.langData.get(theValue, theValue) - ## - # Internal Functions - ## - - def _loadProjectLocalisation(self, theLang): + def loadProjectLocalisation(self, theLang): """Load the language data for the current project language. """ + if theLang is None: + theLang = self.mainConf.spellLanguage + lngShort = theLang.split("_")[0] loadFile = os.path.join(self.mainConf.langPath, "project_en.json") chkFile1 = os.path.join(self.mainConf.langPath, "project_%s.json" % theLang) chkFile2 = os.path.join(self.mainConf.langPath, "project_%s.json" % lngShort) + print(theLang) + print(lngShort) + print(loadFile) + print(chkFile1) + print(chkFile2) if os.path.isfile(chkFile1): loadFile = chkFile1 elif os.path.isfile(chkFile2): @@ -1239,6 +1241,10 @@ class NWProject(): return True + ## + # Internal Functions + ## + def _readLockFile(self): """Reads the lock file in the project folder. """ diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index 4913be25..f50447bb 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -89,6 +89,7 @@ class GuiPreferences(PagedDialog): logger.debug("Saving new preferences") needsRestart = self.tabGeneral.saveValues() + prevSpell = self.mainConf.spellLanguage self.tabProjects.saveValues() self.tabDocs.saveValues() @@ -96,6 +97,9 @@ class GuiPreferences(PagedDialog): self.tabSyntax.saveValues() self.tabAuto.saveValues() + if prevSpell != self.mainConf.spellLanguage: + self.theProject.loadProjectLocalisation(self.mainConf.spellLanguage) + if needsRestart: self.theParent.makeAlert( "Some changes will not be applied until novelWriter has been restarted.",