Make sure the project translation map is loaded correctly

This commit is contained in:
Veronica K. B. Olsen
2021-02-16 22:42:18 +01:00
parent 4699d9404b
commit 8aa2401134
2 changed files with 19 additions and 9 deletions
+15 -9
View File
@@ -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.
"""
+4
View File
@@ -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.",