Skip to content

Commit

Permalink
Last round of changes to localisation
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Feb 16, 2021
1 parent 8093528 commit d5bd816
Show file tree
Hide file tree
Showing 18 changed files with 634 additions and 806 deletions.
1,047 changes: 487 additions & 560 deletions i18n/nw_pt.ts

Large diffs are not rendered by default.

67 changes: 32 additions & 35 deletions novelWriter.pro
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
SOURCES += nw/error.py \
nw/constants/constants.py \
nw/constants/iso.py \
nw/core/document.py \
nw/core/index.py \
nw/core/project.py \
nw/core/tohtml.py \
nw/core/tokenizer.py \
nw/core/tree.py \
nw/guimain.py \
nw/gui/about.py \
nw/gui/build.py \
nw/gui/custom.py \
nw/gui/doceditor.py \
nw/gui/dochighlight.py \
nw/gui/docmerge.py \
nw/gui/docsplit.py \
nw/gui/docviewer.py \
nw/gui/itemdetails.py \
nw/gui/itemeditor.py \
nw/gui/mainmenu.py \
nw/gui/noveltree.py \
nw/gui/outlinedetails.py \
nw/gui/outline.py \
nw/gui/preferences.py \
nw/gui/projdetails.py \
nw/gui/projload.py \
nw/gui/projsettings.py \
nw/gui/projtree.py \
nw/gui/projwizard.py \
nw/gui/statusbar.py \
nw/gui/theme.py \
nw/gui/wordlist.py \
nw/gui/writingstats.py
SOURCES += \
nw/constants/constants.py \
nw/core/document.py \
nw/core/project.py \
nw/core/tokenizer.py \
nw/gui/about.py \
nw/gui/build.py \
nw/gui/custom.py \
nw/gui/doceditor.py \
nw/gui/docmerge.py \
nw/gui/docsplit.py \
nw/gui/docviewer.py \
nw/gui/itemdetails.py \
nw/gui/itemeditor.py \
nw/gui/mainmenu.py \
nw/gui/noveltree.py \
nw/gui/outline.py \
nw/gui/outlinedetails.py \
nw/gui/preferences.py \
nw/gui/projdetails.py \
nw/gui/projload.py \
nw/gui/projsettings.py \
nw/gui/projtree.py \
nw/gui/projwizard.py \
nw/gui/statusbar.py \
nw/gui/theme.py \
nw/gui/wordlist.py \
nw/gui/writingstats.py \
nw/error.py \
nw/guimain.py

TRANSLATIONS += i18n/nw_pt.ts
TRANSLATIONS += \
i18n/nw_pt.ts
37 changes: 12 additions & 25 deletions nw/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def newProject(self, projData={}):

titlePage = "# %s\n\n" % (self.bookTitle if self.bookTitle else self.projName)
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
aDoc = NWDoc(self, self.theParent)
Expand Down Expand Up @@ -516,13 +516,10 @@ def openProject(self, fileName, overrideLock=False):
self.tr("Version Conflict"),
self.tr(
"This project was saved by a newer version of novelWriter, version "
"{new_version}. This is version {version}. If you continue to open the "
"project, some attributes and settings may not be preserved, but the "
"{0}. This is version {1}. If you continue to open the project, "
"some attributes and settings may not be preserved, but the "
"overall project should be fine. Continue opening the project?"
).format(
new_version = appVersion,
version = nw.__version__
)
).format(appVersion, nw.__version__)
)
if not msgYes:
self.clearProject()
Expand Down Expand Up @@ -622,9 +619,7 @@ def openProject(self, fileName, overrideLock=False):
self.mainConf.updateRecentCache(self.projPath, self.projName, self.lastWCount, time())
self.mainConf.saveRecentCache()

self.theParent.setStatus(self.tr("{0}: {1}").format(
self.tr("Opened Project"), self.projName)
)
self.theParent.setStatus(self.tr("Opened Project: {0}").format(self.projName))

self._scanProjectFolder()

Expand Down Expand Up @@ -743,9 +738,7 @@ def saveProject(self, autoSave=False):
self.mainConf.saveRecentCache()

self._writeLockFile()
self.theParent.setStatus(self.tr("{0}: {1}").format(
self.tr("Saved Project"), self.projName)
)
self.theParent.setStatus(self.tr("Saved Project: {0}").format(self.projName))
self.setProjectChanged(False)

return True
Expand Down Expand Up @@ -1503,9 +1496,7 @@ def _legacyDataFolder(self, theFolder, errList):
logger.info("Moved file: %s" % theFile)
logger.info("New location: %s" % newPath)
except Exception:
errList.append(
self.tr("{0}: {1}").format(self.tr("Could not move"), theFile)
)
errList.append(self.tr("Could not move: {0}").format(theFile))
logger.error("Could not move: %s" % theFile)
nw.logException()

Expand All @@ -1514,9 +1505,7 @@ def _legacyDataFolder(self, theFolder, errList):
os.unlink(theFile)
logger.info("Deleted file: %s" % theFile)
except Exception:
errList.append(
self.tr("{0}: {1}").format(self.tr("Could not delete"), theFile)
)
errList.append(self.tr("Could not delete: {0}").format(theFile))
logger.error("Could not delete: %s" % theFile)
nw.logException()

Expand All @@ -1529,12 +1518,10 @@ def _legacyDataFolder(self, theFolder, errList):
# ==================
try:
os.rmdir(theData)
logger.info("Removed folder: %s" % theFolder)
logger.info("Deleted folder: %s" % theFolder)
except Exception:
errList.append(
self.tr("{0}: {1}").format(self.tr("Failed to remove"), theFolder)
)
logger.error("Failed to remove: %s" % theFolder)
errList.append(self.tr("Could not delete: {0}").format(theFolder))
logger.error("Could not delete: %s" % theFolder)
nw.logException()

return errList
Expand All @@ -1545,7 +1532,7 @@ def _moveUnknownItem(self, theDir, theItem):
"""
theJunk = os.path.join(self.projPath, "junk")
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)
theDst = os.path.join(theJunk, theItem)
Expand Down
5 changes: 2 additions & 3 deletions nw/core/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,8 @@ def setText(self, theHandle, theText=None):

docSize = len(self.theText)
if docSize > nwConst.MAX_DOCSIZE:
errVal = self.tr("Document '{doc_name}' is too big ({doc_size}). Skipping.").format(
doc_name = self.theItem.itemName,
doc_size = f"{docSize/1.0e6:.2f} MB"
errVal = self.tr("Document '{0}' is too big ({1}). Skipping.").format(
self.theItem.itemName, f"{docSize/1.0e6:.2f} MB"
)
self.theText = "# %s\n\n%s\n\n" % (self.tr("ERROR"), errVal)
self.errData.append(errVal)
Expand Down
13 changes: 2 additions & 11 deletions nw/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
from time import time
from lxml import etree
from hashlib import sha256
from functools import partial

from PyQt5.QtCore import QCoreApplication

from nw.core.item import NWItem
from nw.common import checkHandle
Expand Down Expand Up @@ -82,9 +79,6 @@ def __init__(self, theProject):

self._handleSeed = None # Used for generating handles for testing

# Internal Mappings
self.tr = partial(QCoreApplication.translate, "NWTree")

return

##
Expand Down Expand Up @@ -201,14 +195,11 @@ def writeToCFile(self):
tocText = os.path.join(self.theProject.projPath, nwFiles.TOC_TXT)
with open(tocText, mode="w", encoding="utf8") as outFile:
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("%-25s %-9s %-10s %s\n" % (
self.tr("File Name"),
self.tr("Class"),
self.tr("Layout"),
self.tr("Document Label"),
"File Name", "Class", "Layout", "Document Label",
))
outFile.write("-"*tocLen + "\n")
outFile.write("\n".join(tocList))
Expand Down
82 changes: 26 additions & 56 deletions nw/gui/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def _fillAboutPage(self):
aboutMsg = "".join([
"<h2>%s</h2>" % self.tr("About novelWriter"),
"<p>{copyright:s}.</p>",
"<p>%s</p>" % self.tr("{0}: {1}").format(
self.tr("Website"), "<a href=\"{website:s}\">{domain:s}</a>"
"<p>%s</p>" % self.tr(
"Website: {0}".format("<a href='{website:s}'>{domain:s}</a>")
),
"<p>%s</p>" % self.tr(
"novelWriter is a markdown-like text editor designed for organising and "
Expand Down Expand Up @@ -174,64 +174,34 @@ def _fillAboutPage(self):
theTheme = self.theParent.theTheme
theIcons = self.theParent.theTheme.theIcons
if theTheme.themeName:
aboutMsg += "".join([
"<h4>%s</h4>" % self.tr("{0}: {1}").format(
self.tr("Theme"), theTheme.themeName
),
"<p>",
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
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>"
])
aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
self.tr("Theme: {0}").format(theTheme.themeName),
self.tr("Author: {0}").format(theTheme.themeAuthor),
self.tr("Credit: {0}").format(theTheme.themeCredit),
self.tr("License: {0}").format(
f"<a href='{theTheme.themeLicenseUrl}'>{theTheme.themeLicense}</a>"
)
)

if theIcons.themeName:
aboutMsg += "".join([
"<h4>%s</h4>" % self.tr("{0}: {1}").format(
self.tr("Icons"), theIcons.themeName
),
"<p>",
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
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>"
])
aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
self.tr("Icons: {0}").format(theIcons.themeName),
self.tr("Author: {0}").format(theIcons.themeAuthor),
self.tr("Credit: {0}").format(theIcons.themeCredit),
self.tr("License: {0}").format(
f"<a href='{theIcons.themeLicenseUrl}'>{theIcons.themeLicense}</a>"
)
)

if theTheme.syntaxName:
aboutMsg += "".join([
"<h4>%s</h4>" % self.tr("{0}: {1}").format(
self.tr("Syntax"), theTheme.syntaxName
),
"<p>",
"%s<br/>" % self.tr("<b>{0}:</b> {1}").format(
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>"
])
aboutMsg += "<h4>%s</h4><p>%s<br/>%s<br/>%s</p>" % (
self.tr("Syntax: {0}").format(theTheme.syntaxName),
self.tr("Author: {0}").format(theTheme.syntaxAuthor),
self.tr("Credit: {0}").format(theTheme.syntaxCredit),
self.tr("License: {0}").format(
f"<a href='{theTheme.syntaxLicenseUrl}'>{theTheme.syntaxLicense}</a>"
)
)

self.pageAbout.setHtml(aboutMsg)

Expand Down
Loading

0 comments on commit d5bd816

Please sign in to comment.