Last round of changes to localisation

This commit is contained in:
Veronica K. B. Olsen
2021-02-16 18:14:04 +01:00
parent 8093528694
commit d5bd816676
18 changed files with 636 additions and 808 deletions
+489 -562
View File
File diff suppressed because it is too large Load Diff
+32 -35
View File
@@ -1,36 +1,33 @@
SOURCES += nw/error.py \ SOURCES += \
nw/constants/constants.py \ nw/constants/constants.py \
nw/constants/iso.py \ nw/core/document.py \
nw/core/document.py \ nw/core/project.py \
nw/core/index.py \ nw/core/tokenizer.py \
nw/core/project.py \ nw/gui/about.py \
nw/core/tohtml.py \ nw/gui/build.py \
nw/core/tokenizer.py \ nw/gui/custom.py \
nw/core/tree.py \ nw/gui/doceditor.py \
nw/guimain.py \ nw/gui/docmerge.py \
nw/gui/about.py \ nw/gui/docsplit.py \
nw/gui/build.py \ nw/gui/docviewer.py \
nw/gui/custom.py \ nw/gui/itemdetails.py \
nw/gui/doceditor.py \ nw/gui/itemeditor.py \
nw/gui/dochighlight.py \ nw/gui/mainmenu.py \
nw/gui/docmerge.py \ nw/gui/noveltree.py \
nw/gui/docsplit.py \ nw/gui/outline.py \
nw/gui/docviewer.py \ nw/gui/outlinedetails.py \
nw/gui/itemdetails.py \ nw/gui/preferences.py \
nw/gui/itemeditor.py \ nw/gui/projdetails.py \
nw/gui/mainmenu.py \ nw/gui/projload.py \
nw/gui/noveltree.py \ nw/gui/projsettings.py \
nw/gui/outlinedetails.py \ nw/gui/projtree.py \
nw/gui/outline.py \ nw/gui/projwizard.py \
nw/gui/preferences.py \ nw/gui/statusbar.py \
nw/gui/projdetails.py \ nw/gui/theme.py \
nw/gui/projload.py \ nw/gui/wordlist.py \
nw/gui/projsettings.py \ nw/gui/writingstats.py \
nw/gui/projtree.py \ nw/error.py \
nw/gui/projwizard.py \ nw/guimain.py
nw/gui/statusbar.py \
nw/gui/theme.py \
nw/gui/wordlist.py \
nw/gui/writingstats.py
TRANSLATIONS += i18n/nw_pt.ts TRANSLATIONS += \
i18n/nw_pt.ts
+12 -25
View File
@@ -260,7 +260,7 @@ class NWProject():
titlePage = "# %s\n\n" % (self.bookTitle if self.bookTitle else self.projName) titlePage = "# %s\n\n" % (self.bookTitle if self.bookTitle else self.projName)
if self.bookAuthors: if self.bookAuthors:
titlePage = "%s%s %s\n" % (titlePage, self.tr("By"), ", ".join(self.bookAuthors)) titlePage = "%s%s %s\n" % (titlePage, self.tr("By"), self.getAuthors())
# Document object for writing files # Document object for writing files
aDoc = NWDoc(self, self.theParent) aDoc = NWDoc(self, self.theParent)
@@ -516,13 +516,10 @@ class NWProject():
self.tr("Version Conflict"), self.tr("Version Conflict"),
self.tr( self.tr(
"This project was saved by a newer version of novelWriter, version " "This project was saved by a newer version of novelWriter, version "
"{new_version}. This is version {version}. If you continue to open the " "{0}. This is version {1}. If you continue to open the project, "
"project, some attributes and settings may not be preserved, but the " "some attributes and settings may not be preserved, but the "
"overall project should be fine. Continue opening the project?" "overall project should be fine. Continue opening the project?"
).format( ).format(appVersion, nw.__version__)
new_version = appVersion,
version = nw.__version__
)
) )
if not msgYes: if not msgYes:
self.clearProject() self.clearProject()
@@ -622,9 +619,7 @@ class NWProject():
self.mainConf.updateRecentCache(self.projPath, self.projName, self.lastWCount, time()) self.mainConf.updateRecentCache(self.projPath, self.projName, self.lastWCount, time())
self.mainConf.saveRecentCache() self.mainConf.saveRecentCache()
self.theParent.setStatus(self.tr("{0}: {1}").format( self.theParent.setStatus(self.tr("Opened Project: {0}").format(self.projName))
self.tr("Opened Project"), self.projName)
)
self._scanProjectFolder() self._scanProjectFolder()
@@ -743,9 +738,7 @@ class NWProject():
self.mainConf.saveRecentCache() self.mainConf.saveRecentCache()
self._writeLockFile() self._writeLockFile()
self.theParent.setStatus(self.tr("{0}: {1}").format( self.theParent.setStatus(self.tr("Saved Project: {0}").format(self.projName))
self.tr("Saved Project"), self.projName)
)
self.setProjectChanged(False) self.setProjectChanged(False)
return True return True
@@ -1503,9 +1496,7 @@ class NWProject():
logger.info("Moved file: %s" % theFile) logger.info("Moved file: %s" % theFile)
logger.info("New location: %s" % newPath) logger.info("New location: %s" % newPath)
except Exception: except Exception:
errList.append( errList.append(self.tr("Could not move: {0}").format(theFile))
self.tr("{0}: {1}").format(self.tr("Could not move"), theFile)
)
logger.error("Could not move: %s" % theFile) logger.error("Could not move: %s" % theFile)
nw.logException() nw.logException()
@@ -1514,9 +1505,7 @@ class NWProject():
os.unlink(theFile) os.unlink(theFile)
logger.info("Deleted file: %s" % theFile) logger.info("Deleted file: %s" % theFile)
except Exception: except Exception:
errList.append( errList.append(self.tr("Could not delete: {0}").format(theFile))
self.tr("{0}: {1}").format(self.tr("Could not delete"), theFile)
)
logger.error("Could not delete: %s" % theFile) logger.error("Could not delete: %s" % theFile)
nw.logException() nw.logException()
@@ -1529,12 +1518,10 @@ class NWProject():
# ================== # ==================
try: try:
os.rmdir(theData) os.rmdir(theData)
logger.info("Removed folder: %s" % theFolder) logger.info("Deleted folder: %s" % theFolder)
except Exception: except Exception:
errList.append( errList.append(self.tr("Could not delete: {0}").format(theFolder))
self.tr("{0}: {1}").format(self.tr("Failed to remove"), theFolder) logger.error("Could not delete: %s" % theFolder)
)
logger.error("Failed to remove: %s" % theFolder)
nw.logException() nw.logException()
return errList return errList
@@ -1545,7 +1532,7 @@ class NWProject():
""" """
theJunk = os.path.join(self.projPath, "junk") theJunk = os.path.join(self.projPath, "junk")
if not self._checkFolder(theJunk): if not self._checkFolder(theJunk):
return self.tr("{0}: {1}").format(self.tr("Could not make folder"), theJunk) return self.tr("Could not make folder: {0}").format(theJunk)
theSrc = os.path.join(theDir, theItem) theSrc = os.path.join(theDir, theItem)
theDst = os.path.join(theJunk, theItem) theDst = os.path.join(theJunk, theItem)
+2 -3
View File
@@ -292,9 +292,8 @@ class Tokenizer():
docSize = len(self.theText) docSize = len(self.theText)
if docSize > nwConst.MAX_DOCSIZE: if docSize > nwConst.MAX_DOCSIZE:
errVal = self.tr("Document '{doc_name}' is too big ({doc_size}). Skipping.").format( errVal = self.tr("Document '{0}' is too big ({1}). Skipping.").format(
doc_name = self.theItem.itemName, self.theItem.itemName, f"{docSize/1.0e6:.2f} MB"
doc_size = f"{docSize/1.0e6:.2f} MB"
) )
self.theText = "# %s\n\n%s\n\n" % (self.tr("ERROR"), errVal) self.theText = "# %s\n\n%s\n\n" % (self.tr("ERROR"), errVal)
self.errData.append(errVal) self.errData.append(errVal)
+2 -11
View File
@@ -31,9 +31,6 @@ import os
from time import time from time import time
from lxml import etree from lxml import etree
from hashlib import sha256 from hashlib import sha256
from functools import partial
from PyQt5.QtCore import QCoreApplication
from nw.core.item import NWItem from nw.core.item import NWItem
from nw.common import checkHandle from nw.common import checkHandle
@@ -82,9 +79,6 @@ class NWTree():
self._handleSeed = None # Used for generating handles for testing self._handleSeed = None # Used for generating handles for testing
# Internal Mappings
self.tr = partial(QCoreApplication.translate, "NWTree")
return return
## ##
@@ -201,14 +195,11 @@ class NWTree():
tocText = os.path.join(self.theProject.projPath, nwFiles.TOC_TXT) tocText = os.path.join(self.theProject.projPath, nwFiles.TOC_TXT)
with open(tocText, mode="w", encoding="utf8") as outFile: with open(tocText, mode="w", encoding="utf8") as outFile:
outFile.write("\n") outFile.write("\n")
outFile.write("%s\n" % self.tr("Table of Contents")) outFile.write("Table of Contents\n")
outFile.write("=================\n") outFile.write("=================\n")
outFile.write("\n") outFile.write("\n")
outFile.write("%-25s %-9s %-10s %s\n" % ( outFile.write("%-25s %-9s %-10s %s\n" % (
self.tr("File Name"), "File Name", "Class", "Layout", "Document Label",
self.tr("Class"),
self.tr("Layout"),
self.tr("Document Label"),
)) ))
outFile.write("-"*tocLen + "\n") outFile.write("-"*tocLen + "\n")
outFile.write("\n".join(tocList)) outFile.write("\n".join(tocList))
+26 -56
View File
@@ -136,8 +136,8 @@ class GuiAbout(QDialog):
aboutMsg = "".join([ aboutMsg = "".join([
"<h2>%s</h2>" % self.tr("About novelWriter"), "<h2>%s</h2>" % self.tr("About novelWriter"),
"<p>{copyright:s}.</p>", "<p>{copyright:s}.</p>",
"<p>%s</p>" % self.tr("{0}: {1}").format( "<p>%s</p>" % self.tr(
self.tr("Website"), "<a href=\"{website:s}\">{domain:s}</a>" "Website: {0}".format("<a href='{website:s}'>{domain:s}</a>")
), ),
"<p>%s</p>" % self.tr( "<p>%s</p>" % self.tr(
"novelWriter is a markdown-like text editor designed for organising and " "novelWriter is a markdown-like text editor designed for organising and "
@@ -174,64 +174,34 @@ class GuiAbout(QDialog):
theTheme = self.theParent.theTheme theTheme = self.theParent.theTheme
theIcons = self.theParent.theTheme.theIcons theIcons = self.theParent.theTheme.theIcons
if theTheme.themeName: if theTheme.themeName:
aboutMsg += "".join([ aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
"<h4>%s</h4>" % self.tr("{0}: {1}").format( self.tr("Theme: {0}").format(theTheme.themeName),
self.tr("Theme"), theTheme.themeName self.tr("Author: {0}").format(theTheme.themeAuthor),
), self.tr("Credit: {0}").format(theTheme.themeCredit),
"<p>", self.tr("License: {0}").format(
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format( f"<a href='{theTheme.themeLicenseUrl}'>{theTheme.themeLicense}</a>"
self.tr("Author"), theTheme.themeAuthor )
), )
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
self.tr("Credit"), theTheme.themeCredit
),
self.tr("<b>{0}:</b> {1}").format(
self.tr("License"), "<a href='{0}'>{1}</a>".format(
theTheme.themeLicenseUrl, theTheme.themeLicense
)
),
"</p>"
])
if theIcons.themeName: if theIcons.themeName:
aboutMsg += "".join([ aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
"<h4>%s</h4>" % self.tr("{0}: {1}").format( self.tr("Icons: {0}").format(theIcons.themeName),
self.tr("Icons"), theIcons.themeName self.tr("Author: {0}").format(theIcons.themeAuthor),
), self.tr("Credit: {0}").format(theIcons.themeCredit),
"<p>", self.tr("License: {0}").format(
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format( f"<a href='{theIcons.themeLicenseUrl}'>{theIcons.themeLicense}</a>"
self.tr("Author"), theIcons.themeAuthor )
), )
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
self.tr("Credit"), theIcons.themeCredit
),
self.tr("<b>{0}:</b> {1}").format(
self.tr("License"), "<a href='{0}'>{1}</a>".format(
theIcons.themeLicenseUrl, theIcons.themeLicense
)
),
"</p>"
])
if theTheme.syntaxName: if theTheme.syntaxName:
aboutMsg += "".join([ aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
"<h4>%s</h4>" % self.tr("{0}: {1}").format( self.tr("Syntax: {0}").format(theTheme.syntaxName),
self.tr("Syntax"), theTheme.syntaxName self.tr("Author: {0}").format(theTheme.syntaxAuthor),
), self.tr("Credit: {0}").format(theTheme.syntaxCredit),
"<p>", self.tr("License: {0}").format(
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format( f"<a href='{theTheme.syntaxLicenseUrl}'>{theTheme.syntaxLicense}</a>"
self.tr("Author"), theTheme.syntaxAuthor )
), )
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
self.tr("Credit"), theTheme.syntaxCredit
),
self.tr("<b>{0}:</b> {1}").format(
self.tr("License"), "<a href='{0}'>{1}</a>".format(
theTheme.syntaxLicenseUrl, theTheme.syntaxLicense
)
),
"</p>"
])
self.pageAbout.setHtml(aboutMsg) self.pageAbout.setHtml(aboutMsg)
+13 -32
View File
@@ -106,7 +106,7 @@ class GuiBuildNovel(QDialog):
self.titleGroup.setLayout(self.titleForm) self.titleGroup.setLayout(self.titleForm)
fmtHelp = "<br>".join([ fmtHelp = "<br>".join([
"<b>%s</b>" % self.tr("{0}:").format("Formatting Codes"), "<b>%s</b>" % self.tr("Formatting Codes:"),
self.tr("{0} for the title as set in the document").format(r"%title%"), self.tr("{0} for the title as set in the document").format(r"%title%"),
self.tr("{0} for chapter number (1, 2, 3)").format(r"%ch%"), self.tr("{0} for chapter number (1, 2, 3)").format(r"%ch%"),
self.tr("{0} for chapter number as a word (one, two)").format(r"%chw%"), self.tr("{0} for chapter number as a word (one, two)").format(r"%chw%"),
@@ -423,54 +423,38 @@ class GuiBuildNovel(QDialog):
# Saving to File # Saving to File
self.saveMenu = QMenu(self) self.saveMenu = QMenu(self)
self.btnSave = QPushButton("Save As") self.btnSave = QPushButton(self.tr("Save As"))
self.btnSave.setMenu(self.saveMenu) self.btnSave.setMenu(self.saveMenu)
self.saveODT = QAction( self.saveODT = QAction(self.tr("Open Document (.odt)"), self)
self.tr("{0} ({1})").format(self.tr("Open Document"), ".odt"), self
)
self.saveODT.triggered.connect(lambda: self._saveDocument(self.FMT_ODT)) self.saveODT.triggered.connect(lambda: self._saveDocument(self.FMT_ODT))
self.saveMenu.addAction(self.saveODT) self.saveMenu.addAction(self.saveODT)
self.saveFODT = QAction( self.saveFODT = QAction(self.tr("Flat Open Document (.fodt)"), self)
self.tr("{0} ({1})").format(self.tr("Flat Open Document"), ".fodt"), self
)
self.saveFODT.triggered.connect(lambda: self._saveDocument(self.FMT_FODT)) self.saveFODT.triggered.connect(lambda: self._saveDocument(self.FMT_FODT))
self.saveMenu.addAction(self.saveFODT) self.saveMenu.addAction(self.saveFODT)
self.saveHTM = QAction( self.saveHTM = QAction(self.tr("novelWriter HTML (.htm)"), self)
self.tr("{0} ({1})").format(self.tr("novelWriter HTML"), ".htm"), self
)
self.saveHTM.triggered.connect(lambda: self._saveDocument(self.FMT_HTM)) self.saveHTM.triggered.connect(lambda: self._saveDocument(self.FMT_HTM))
self.saveMenu.addAction(self.saveHTM) self.saveMenu.addAction(self.saveHTM)
self.saveNWD = QAction( self.saveNWD = QAction(self.tr("novelWriter Markdown (.nwd)"), self)
self.tr("{0} ({1})").format(self.tr("novelWriter Markdown"), ".nwd"), self
)
self.saveNWD.triggered.connect(lambda: self._saveDocument(self.FMT_NWD)) self.saveNWD.triggered.connect(lambda: self._saveDocument(self.FMT_NWD))
self.saveMenu.addAction(self.saveNWD) self.saveMenu.addAction(self.saveNWD)
self.saveMD = QAction( self.saveMD = QAction(self.tr("Standard Markdown (.md)"), self)
self.tr("{0} ({1})").format(self.tr("Standard Markdown"), ".md"), self
)
self.saveMD.triggered.connect(lambda: self._saveDocument(self.FMT_MD)) self.saveMD.triggered.connect(lambda: self._saveDocument(self.FMT_MD))
self.saveMenu.addAction(self.saveMD) self.saveMenu.addAction(self.saveMD)
self.saveGH = QAction( self.saveGH = QAction(self.tr("GitHub Markdown (.md)"), self)
self.tr("{0} ({1})").format(self.tr("GitHub Markdown"), ".md"), self
)
self.saveGH.triggered.connect(lambda: self._saveDocument(self.FMT_GH)) self.saveGH.triggered.connect(lambda: self._saveDocument(self.FMT_GH))
self.saveMenu.addAction(self.saveGH) self.saveMenu.addAction(self.saveGH)
self.saveJsonH = QAction( self.saveJsonH = QAction(self.tr("JSON + novelWriter HTML (.json)"), self)
self.tr("{0} ({1})").format(self.tr("JSON + novelWriter HTML"), ".json"), self
)
self.saveJsonH.triggered.connect(lambda: self._saveDocument(self.FMT_JSON_H)) self.saveJsonH.triggered.connect(lambda: self._saveDocument(self.FMT_JSON_H))
self.saveMenu.addAction(self.saveJsonH) self.saveMenu.addAction(self.saveJsonH)
self.saveJsonM = QAction( self.saveJsonM = QAction(self.tr("JSON + novelWriters Markdown (.json)"), self)
self.tr("{0} ({1})").format(self.tr("JSON + novelWriters Markdown"), ".json"), self
)
self.saveJsonM.triggered.connect(lambda: self._saveDocument(self.FMT_JSON_M)) self.saveJsonM.triggered.connect(lambda: self._saveDocument(self.FMT_JSON_M))
self.saveMenu.addAction(self.saveJsonM) self.saveMenu.addAction(self.saveJsonM)
@@ -1241,9 +1225,7 @@ class GuiBuildNovelDocView(QTextBrowser):
fPx = int(1.1*self.theTheme.fontPixelSize) fPx = int(1.1*self.theTheme.fontPixelSize)
self.theTitle = QLabel(self.tr("<b>{0}:</b> {1}".format( self.theTitle = QLabel("")
self.tr("Build Time"), self.tr("Unknown"))), self
)
self.theTitle.setIndent(0) self.theTitle.setIndent(0)
self.theTitle.setAutoFillBackground(True) self.theTitle.setAutoFillBackground(True)
self.theTitle.setAlignment(Qt.AlignCenter) self.theTitle.setAlignment(Qt.AlignCenter)
@@ -1252,6 +1234,7 @@ class GuiBuildNovelDocView(QTextBrowser):
self.theTitle.setFont(lblFont) self.theTitle.setFont(lblFont)
self._updateDocMargins() self._updateDocMargins()
self._updateBuildAge()
self.setStyleSheet() self.setStyleSheet()
# Age Timer # Age Timer
@@ -1359,9 +1342,7 @@ class GuiBuildNovelDocView(QTextBrowser):
else: else:
strBuildTime = self.tr("Unknown") strBuildTime = self.tr("Unknown")
self.theTitle.setText(self.tr("<b>{0}:</b> {1}").format( self.theTitle.setText(self.tr("<b>Build Time:</b> {0}").format(strBuildTime))
self.tr("Build Time"), strBuildTime)
)
return return
+26 -33
View File
@@ -296,11 +296,11 @@ class GuiDocEditor(QTextEdit):
self.theParent.makeAlert( self.theParent.makeAlert(
self.tr( self.tr(
"The document you are trying to open is too big. " "The document you are trying to open is too big. "
"The document size is {doc_size}. " "The document size is {0} MB. "
"The maximum size allowed is {max_size}." "The maximum size allowed is {1} MB."
).format( ).format(
doc_size=self.tr("{0}\u202fMB").format(f"{docSize/1.0e6:.2f}"), f"{docSize/1.0e6:.2f}",
max_size=self.tr("{0}\u202fMB").format(f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}") f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), ),
nwAlert.ERROR nwAlert.ERROR
) )
@@ -389,11 +389,11 @@ class GuiDocEditor(QTextEdit):
self.theParent.makeAlert( self.theParent.makeAlert(
self.tr( self.tr(
"The text you are trying to add is too big. " "The text you are trying to add is too big. "
"The text size is {text_size}. " "The text size is {0} MB. "
"The maximum size allowed is {max_size}." "The maximum size allowed is {1} MB."
).format( ).format(
text_size=self.tr("{0}\u202fMB").format(f"{docSize/1.0e6:.2f}"), f"{docSize/1.0e6:.2f}",
max_size=self.tr("{0}\u202fMB").format(f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}") f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), ),
nwAlert.ERROR nwAlert.ERROR
) )
@@ -580,12 +580,14 @@ class GuiDocEditor(QTextEdit):
""" """
if not isinstance(theLine, int): if not isinstance(theLine, int):
return False return False
if theLine >= 0: if theLine >= 0:
theBlock = self.qDocument.findBlockByLineNumber(theLine) theBlock = self.qDocument.findBlockByLineNumber(theLine)
if theBlock: if theBlock:
self.setCursorPosition(theBlock.position()) self.setCursorPosition(theBlock.position())
self.docFooter.updateLineCount() self.docFooter.updateLineCount()
logger.verbose("Cursor moved to line %d" % theLine) logger.verbose("Cursor moved to line %d" % theLine)
return True return True
## ##
@@ -651,9 +653,7 @@ class GuiDocEditor(QTextEdit):
self.hLight.rehighlight() self.hLight.rehighlight()
qApp.restoreOverrideCursor() qApp.restoreOverrideCursor()
afTime = time() afTime = time()
logger.debug( logger.debug("Document highlighted in %.3f ms" % (1000*(afTime-bfTime)))
"Document highlighted in %.3f ms" % (1000*(afTime-bfTime))
)
self.theParent.statusBar.showMessage(self.tr("Spell check complete")) self.theParent.statusBar.showMessage(self.tr("Spell check complete"))
return True return True
@@ -809,7 +809,7 @@ class GuiDocEditor(QTextEdit):
theCursor = self.textCursor() theCursor = self.textCursor()
theBlock = theCursor.block() theBlock = theCursor.block()
if not theBlock.isValid(): if not theBlock.isValid():
logger.error("Filed to insert keyword '%s'" % keyWord) logger.error("Failed to insert keyword '%s'" % keyWord)
return False return False
theCursor.beginEditBlock() theCursor.beginEditBlock()
@@ -946,9 +946,9 @@ class GuiDocEditor(QTextEdit):
self.theParent.makeAlert( self.theParent.makeAlert(
self.tr( self.tr(
"The document has grown too big and you cannot add more text to it. " "The document has grown too big and you cannot add more text to it. "
"The maximum size of a single novelWriter document is {max_size}." "The maximum size of a single novelWriter document is {0} MB."
).format( ).format(
max_size=self.tr("{0}\u202fMB").format(f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}") f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), ),
nwAlert.ERROR nwAlert.ERROR
) )
@@ -1052,8 +1052,9 @@ class GuiDocEditor(QTextEdit):
) )
mnuContext.addAction(mnuWord) mnuContext.addAction(mnuWord)
else: else:
mnuHead = QAction("%s %s" % (nwUnicode.U_ENDASH, self.tr("No Suggestions")), mnuHead = QAction(
mnuContext) "%s %s" % (nwUnicode.U_ENDASH, self.tr("No Suggestions")), mnuContext
)
mnuContext.addAction(mnuHead) mnuContext.addAction(mnuHead)
mnuContext.addSeparator() mnuContext.addSeparator()
@@ -1147,15 +1148,11 @@ class GuiDocEditor(QTextEdit):
QPointF(theSize.width(), theSize.height()), Qt.FuzzyHit QPointF(theSize.width(), theSize.height()), Qt.FuzzyHit
) )
if self.queuePos <= thePos: if self.queuePos <= thePos:
logger.verbose( logger.verbose("Allowed cursor move to %d <= %d" % (self.queuePos, thePos))
"Allowed cursor move to %d <= %d" % (self.queuePos, thePos)
)
self.setCursorPosition(self.queuePos) self.setCursorPosition(self.queuePos)
self.queuePos = None self.queuePos = None
else: else:
logger.verbose( logger.verbose("Denied cursor move to %d > %d" % (self.queuePos, thePos))
"Denied cursor move to %d > %d" % (self.queuePos, thePos)
)
return return
## ##
@@ -1547,9 +1544,7 @@ class GuiDocEditor(QTextEdit):
theText = newText theText = newText
cOffset -= 0 cOffset -= 0
else: else:
logger.error( logger.error("Unknown or unsupported block format requested: %s" % str(docAction))
"Unknown or unsupported block format requested: %s" % str(docAction)
)
return False return False
# Replace the block text # Replace the block text
@@ -2446,7 +2441,7 @@ class GuiDocEditFooter(QWidget):
self.linesIcon.setFixedHeight(self.sPx) self.linesIcon.setFixedHeight(self.sPx)
self.linesIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.linesIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.linesText = QLabel(self.tr("{0}: {1}").format(self.tr("Line"), "0")) self.linesText = QLabel("")
self.linesText.setIndent(0) self.linesText.setIndent(0)
self.linesText.setMargin(0) self.linesText.setMargin(0)
self.linesText.setContentsMargins(0, 0, 0, 0) self.linesText.setContentsMargins(0, 0, 0, 0)
@@ -2462,7 +2457,7 @@ class GuiDocEditFooter(QWidget):
self.wordsIcon.setFixedHeight(self.sPx) self.wordsIcon.setFixedHeight(self.sPx)
self.wordsIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.wordsIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.wordsText = QLabel(self.tr("{0}: {1}").format(self.tr("Words"), "0")) self.wordsText = QLabel("")
self.wordsText.setIndent(0) self.wordsText.setIndent(0)
self.wordsText.setMargin(0) self.wordsText.setMargin(0)
self.wordsText.setContentsMargins(0, 0, 0, 0) self.wordsText.setContentsMargins(0, 0, 0, 0)
@@ -2493,6 +2488,8 @@ class GuiDocEditFooter(QWidget):
# Fix the Colours # Fix the Colours
self.matchColours() self.matchColours()
self.updateLineCount()
self.updateCounts()
logger.debug("GuiDocEditFooter initialisation complete") logger.debug("GuiDocEditFooter initialisation complete")
@@ -2570,9 +2567,7 @@ class GuiDocEditFooter(QWidget):
iDist = 100*iLine/self.docEditor.qDocument.blockCount() iDist = 100*iLine/self.docEditor.qDocument.blockCount()
self.linesText.setText( self.linesText.setText(
self.tr("{0}: {1} ({2}\u202f%%)".format( self.tr("Line: {0} ({1})").format(f"{iLine:n}", f"{iDist:.0f} %")
self.tr("Line"), f"{iLine:n}", f"{iDist:.0f}")
)
) )
return return
@@ -2588,9 +2583,7 @@ class GuiDocEditFooter(QWidget):
wDiff = wCount - self.theItem.initCount wDiff = wCount - self.theItem.initCount
self.wordsText.setText( self.wordsText.setText(
self.tr("{0}: {1} ({2})".format( self.tr("Words: {0} ({1})").format(f"{wCount:n}", f"{wDiff:+n}")
self.tr("Words"), f"{wCount:n}", f"{wDiff:+n}")
)
) )
byteSize = self.docEditor.qDocument.characterCount() byteSize = self.docEditor.qDocument.characterCount()
+3 -5
View File
@@ -958,11 +958,9 @@ class GuiDocViewFooter(QWidget):
self.stickyRefs.setIconSize(QSize(fPx, fPx)) self.stickyRefs.setIconSize(QSize(fPx, fPx))
self.stickyRefs.setFixedSize(QSize(fPx, fPx)) self.stickyRefs.setFixedSize(QSize(fPx, fPx))
self.stickyRefs.toggled.connect(self._doToggleSticky) self.stickyRefs.toggled.connect(self._doToggleSticky)
self.stickyRefs.setToolTip( self.stickyRefs.setToolTip(self.tr(
self.tr( "Activate to freeze the content of the references panel when changing document"
"Activate to freeze the content of the references panel when changing document" ))
)
)
# Show Comments # Show Comments
self.showComments = QToolButton(self) self.showComments = QToolButton(self)
+9 -6
View File
@@ -390,8 +390,9 @@ class GuiMainMenu(QMenuBar):
# Document > Split Document # Document > Split Document
self.aSplitDoc = QAction(self.tr("Split Document to Folder"), self) self.aSplitDoc = QAction(self.tr("Split Document to Folder"), self)
self.aSplitDoc.setStatusTip(self.tr("Split a document into a folder of " self.aSplitDoc.setStatusTip(
"multiple documents")) self.tr("Split a document into a folder of multiple documents")
)
self.aSplitDoc.triggered.connect(lambda: self.theParent.splitDocument()) self.aSplitDoc.triggered.connect(lambda: self.theParent.splitDocument())
self.docuMenu.addAction(self.aSplitDoc) self.docuMenu.addAction(self.aSplitDoc)
@@ -516,8 +517,9 @@ class GuiMainMenu(QMenuBar):
# View > Focus Mode # View > Focus Mode
self.aFocusMode = QAction(self.tr("Focus Mode"), self) self.aFocusMode = QAction(self.tr("Focus Mode"), self)
self.aFocusMode.setStatusTip(self.tr("Toggles a distraction free mode, " self.aFocusMode.setStatusTip(
"only showing text editor")) self.tr("Toggles a distraction free mode, only showing text editor")
)
self.aFocusMode.setShortcut("F8") self.aFocusMode.setShortcut("F8")
self.aFocusMode.setCheckable(True) self.aFocusMode.setCheckable(True)
self.aFocusMode.setChecked(self.theParent.isFocusMode) self.aFocusMode.setChecked(self.theParent.isFocusMode)
@@ -961,8 +963,9 @@ class GuiMainMenu(QMenuBar):
# Tools > Toggle Auto Build Outline # Tools > Toggle Auto Build Outline
self.aAutoOutline = QAction(self.tr("Auto-Update Outline"), self) self.aAutoOutline = QAction(self.tr("Auto-Update Outline"), self)
self.aAutoOutline.setStatusTip(self.tr( self.aAutoOutline.setStatusTip(
"Update project outline when a novel file is changed")) self.tr("Update project outline when a novel file is changed")
)
self.aAutoOutline.setCheckable(True) self.aAutoOutline.setCheckable(True)
self.aAutoOutline.toggled.connect(self._toggleAutoOutline) self.aAutoOutline.toggled.connect(self._toggleAutoOutline)
self.aAutoOutline.setShortcut("Ctrl+F10") self.aAutoOutline.setShortcut("Ctrl+F10")
+2 -2
View File
@@ -336,7 +336,7 @@ class GuiPreferencesProjects(QWidget):
self.backupPathRow = self.mainForm.addRow( self.backupPathRow = self.mainForm.addRow(
self.tr("Backup storage location"), self.tr("Backup storage location"),
self.backupGetPath, self.backupGetPath,
self.tr("{0}: {1}").format(self.tr("Path"), self.backupPath) self.tr("Path: {0}").format(self.backupPath)
) )
## Run when closing ## Run when closing
@@ -429,7 +429,7 @@ class GuiPreferencesProjects(QWidget):
if newDir: if newDir:
self.backupPath = newDir self.backupPath = newDir
self.mainForm.setHelpText( self.mainForm.setHelpText(
self.backupPathRow, self.tr("{0}: {1}").format(self.tr("Path"), self.backupPath)) self.backupPathRow, self.tr("Path: {0}").format(self.backupPath))
return True return True
return False return False
+1 -3
View File
@@ -156,9 +156,7 @@ class GuiProjectDetailsMain(QWidget):
self.bookTitle.setWordWrap(True) self.bookTitle.setWordWrap(True)
self.projName = QLabel( self.projName = QLabel(
self.tr("{0}: {1}").format( self.tr("Working Title: {0}").format(self.theProject.projName)
self.tr("Working Title"), self.theProject.projName
)
) )
workFont = self.projName.font() workFont = self.projName.font()
workFont.setPointSizeF(0.8*fPt) workFont.setPointSizeF(0.8*fPt)
+2 -4
View File
@@ -191,10 +191,8 @@ class GuiProjectLoad(QDialog):
projFile, _ = QFileDialog.getOpenFileName( projFile, _ = QFileDialog.getOpenFileName(
self, self.tr("Open novelWriter Project"), "", self, self.tr("Open novelWriter Project"), "",
";;".join([ ";;".join([
self.tr("{0} ({1})").format( self.tr("novelWriter Project File ({0})").format(nwFiles.PROJ_FILE),
self.tr("novelWriter Project File"), nwFiles.PROJ_FILE self.tr("All Files (*.*)"),
),
self.tr("{0} ({1})").format(self.tr("All Files"), "*")
]), ]),
options=dlgOpt options=dlgOpt
) )
+1 -1
View File
@@ -466,7 +466,7 @@ class GuiProjectEditReplace(QWidget):
self.listBox.setIndentation(0) self.listBox.setIndentation(0)
for aKey, aVal in self.theProject.autoReplace.items(): for aKey, aVal in self.theProject.autoReplace.items():
newItem = QTreeWidgetItem([self.tr("<{0}>").format(aKey), aVal]) newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
self.listBox.addTopLevelItem(newItem) self.listBox.addTopLevelItem(newItem)
self.listBox.sortByColumn(0, Qt.AscendingOrder) self.listBox.sortByColumn(0, Qt.AscendingOrder)
+2 -3
View File
@@ -105,9 +105,8 @@ class ProjWizardIntroPage(QWizardPage):
) )
self.theText.setWordWrap(True) self.theText.setWordWrap(True)
self.imgCredit = QLabel(self.tr("Side image by {author:s}, {license:s}").format( self.imgCredit = QLabel(self.tr("Side image by {0}, {1}").format(
author = "Peter Mitterhofer", "Peter Mitterhofer", "CC BY-SA 4.0"
license = "CC BY-SA 4.0"
)) ))
lblFont = self.imgCredit.font() lblFont = self.imgCredit.font()
lblFont.setPointSizeF(0.6*self.theTheme.fontPointSize) lblFont.setPointSizeF(0.6*self.theTheme.fontPointSize)
+1 -3
View File
@@ -179,9 +179,7 @@ class GuiMainStatus(QStatusBar):
def setStats(self, pWC, sWC): def setStats(self, pWC, sWC):
"""Set the current project statistics. """Set the current project statistics.
""" """
self.statsText.setText(self.tr("{0}: {1} ({2})").format( self.statsText.setText(self.tr("Words: {0} ({1})").format(f"{pWC:n}", f"{sWC:+n}"))
self.tr("Words"), f"{pWC:n}", f"{sWC:+n}")
)
self.statsText.setToolTip(self.tr("Project word count (session change)")) self.statsText.setToolTip(self.tr("Project word count (session change)"))
return return
+8 -10
View File
@@ -159,12 +159,12 @@ class GuiWritingStats(QDialog):
self.totalWords.setFont(self.theTheme.guiFontFixed) self.totalWords.setFont(self.theTheme.guiFontFixed)
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
lblTTime = QLabel(self.tr("{0}:").format(self.tr("Total Time"))) lblTTime = QLabel(self.tr("Total Time:"))
lblITime = QLabel(self.tr("{0}:").format(self.tr("Idle Time"))) lblITime = QLabel(self.tr("Idle Time:"))
lblFTime = QLabel(self.tr("{0}:").format(self.tr("Filtered Time"))) lblFTime = QLabel(self.tr("Filtered Time:"))
lblNvCount = QLabel(self.tr("{0}:").format(self.tr("Novel Word Count"))) lblNvCount = QLabel(self.tr("Novel Word Count:"))
lblNtCount = QLabel(self.tr("{0}:").format(self.tr("Notes Word Count"))) lblNtCount = QLabel(self.tr("Notes Word Count:"))
lblTtCount = QLabel(self.tr("{0}:").format(self.tr("Total Word Count"))) lblTtCount = QLabel(self.tr("Total Word Count:"))
self.infoForm.addWidget(lblTTime, 0, 0) self.infoForm.addWidget(lblTTime, 0, 0)
self.infoForm.addWidget(lblITime, 1, 0) self.infoForm.addWidget(lblITime, 1, 0)
@@ -268,13 +268,11 @@ class GuiWritingStats(QDialog):
self.saveMenu = QMenu(self) self.saveMenu = QMenu(self)
self.btnSave.setMenu(self.saveMenu) self.btnSave.setMenu(self.saveMenu)
self.saveJSON = QAction(self.tr("{0} ({1})").format( self.saveJSON = QAction(self.tr("JSON Data File (.json)"), self)
self.tr("JSON Data File"), ".json"), self)
self.saveJSON.triggered.connect(lambda: self._saveData(self.FMT_JSON)) self.saveJSON.triggered.connect(lambda: self._saveData(self.FMT_JSON))
self.saveMenu.addAction(self.saveJSON) self.saveMenu.addAction(self.saveJSON)
self.saveCSV = QAction(self.tr("{0} ({1})").format( self.saveCSV = QAction(self.tr("CSV Data File (.csv)"), self)
self.tr("CSV Data File"), ".csv"), self)
self.saveCSV.triggered.connect(lambda: self._saveData(self.FMT_CSV)) self.saveCSV.triggered.connect(lambda: self._saveData(self.FMT_CSV))
self.saveMenu.addAction(self.saveCSV) self.saveMenu.addAction(self.saveCSV)
+5 -14
View File
@@ -725,13 +725,9 @@ class GuiMain(QMainWindow):
theText = inFile.read() theText = inFile.read()
self.mainConf.setLastPath(loadFile) self.mainConf.setLastPath(loadFile)
except Exception as e: except Exception as e:
self.makeAlert( self.makeAlert([
[ self.tr("Could not read file. The file must be an existing text file."), str(e)
self.tr("Could not read file. The file must be an existing text file."), ], nwAlert.ERROR)
str(e)
],
nwAlert.ERROR
)
return False return False
if self.docEditor.theHandle is None: if self.docEditor.theHandle is None:
@@ -885,14 +881,9 @@ class GuiMain(QMainWindow):
for nDone, tItem in enumerate(self.theProject.projTree): for nDone, tItem in enumerate(self.theProject.projTree):
if tItem is not None: if tItem is not None:
self.setStatus(self.tr("{0}: '{1}'").format(self.tr("Indexing"), tItem.itemName)) self.setStatus(self.tr("Indexing: '{0}'").format(tItem.itemName))
else: else:
self.setStatus( self.setStatus(self.tr("Indexing: '{0}'").format(self.tr("Unknown item")))
self.tr("{0}: {1}").format(
self.tr("Indexing"),
self.tr("Unknown item")
)
)
if tItem is not None and tItem.itemType == nwItemType.FILE: if tItem is not None and tItem.itemType == nwItemType.FILE:
logger.verbose("Scanning: %s" % tItem.itemName) logger.verbose("Scanning: %s" % tItem.itemName)