Merge pull request #684 from vkbo/qt_translations

Qt Widget Translations
This commit is contained in:
Veronica Berglyd Olsen
2021-02-20 13:48:57 +01:00
committed by GitHub
24 changed files with 934 additions and 776 deletions
+74
View File
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
"""
Dummy Qt Translation File
=========================
This file causes Qt Linguist to generate translation entries for the Qt
elements that need translation in novelWriter for those languages who do
not yet have a qtbase_xx.qm file shipped with Qt.
If a qtbase_xx.qm file already exists, do not add a translation for the
entries generated from this file.
"""
from PyQt5.QtCore import QT_TRANSLATE_NOOP
# QDialogButtonBox
# ================
QT_TRANSLATE_NOOP("QDialogButtonBox", "OK")
# QGnomeTheme
# ===========
QT_TRANSLATE_NOOP("QGnomeTheme", "&OK")
QT_TRANSLATE_NOOP("QGnomeTheme", "&Save")
QT_TRANSLATE_NOOP("QGnomeTheme", "&Cancel")
QT_TRANSLATE_NOOP("QGnomeTheme", "&Close")
QT_TRANSLATE_NOOP("QGnomeTheme", "Close without Saving")
# QGuiApplication
# ===============
QT_TRANSLATE_NOOP("QGuiApplication", (
"Translate this string to the string 'LTR' in left-to-right languages or to "
"'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout."
))
# QPlatformTheme
# ==============
QT_TRANSLATE_NOOP("QPlatformTheme", "OK")
QT_TRANSLATE_NOOP("QPlatformTheme", "Save")
QT_TRANSLATE_NOOP("QPlatformTheme", "Save All")
QT_TRANSLATE_NOOP("QPlatformTheme", "Open")
QT_TRANSLATE_NOOP("QPlatformTheme", "&Yes")
QT_TRANSLATE_NOOP("QPlatformTheme", "Yes to &All")
QT_TRANSLATE_NOOP("QPlatformTheme", "&No")
QT_TRANSLATE_NOOP("QPlatformTheme", "N&o to All")
QT_TRANSLATE_NOOP("QPlatformTheme", "Abort")
QT_TRANSLATE_NOOP("QPlatformTheme", "Retry")
QT_TRANSLATE_NOOP("QPlatformTheme", "Ignore")
QT_TRANSLATE_NOOP("QPlatformTheme", "Close")
QT_TRANSLATE_NOOP("QPlatformTheme", "Cancel")
QT_TRANSLATE_NOOP("QPlatformTheme", "Discard")
QT_TRANSLATE_NOOP("QPlatformTheme", "Help")
QT_TRANSLATE_NOOP("QPlatformTheme", "Apply")
QT_TRANSLATE_NOOP("QPlatformTheme", "Reset")
QT_TRANSLATE_NOOP("QPlatformTheme", "Restore Defaults")
# QWizard
# =======
QT_TRANSLATE_NOOP("QWizard", "Go Back")
QT_TRANSLATE_NOOP("QWizard", "< &Back")
QT_TRANSLATE_NOOP("QWizard", "Continue")
QT_TRANSLATE_NOOP("QWizard", "&Next")
QT_TRANSLATE_NOOP("QWizard", "&Next >")
QT_TRANSLATE_NOOP("QWizard", "Commit")
QT_TRANSLATE_NOOP("QWizard", "Done")
QT_TRANSLATE_NOOP("QWizard", "&Finish")
QT_TRANSLATE_NOOP("QWizard", "Cancel")
QT_TRANSLATE_NOOP("QWizard", "Cancel")
QT_TRANSLATE_NOOP("QWizard", "Help")
QT_TRANSLATE_NOOP("QWizard", "&Help")
+418 -342
View File
File diff suppressed because it is too large Load Diff
+418 -342
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -1,4 +1,5 @@
SOURCES += \
i18n/dummy_qtbase.py \
nw/constants/constants.py \
nw/core/document.py \
nw/core/project.py \
+4 -4
View File
@@ -221,14 +221,14 @@ def main(sysArgs=None):
"At least Python 3.6.0 is required, found %s." % CONFIG.verPyString
)
errorCode |= 4
if CONFIG.verQtValue < 50200:
if CONFIG.verQtValue < 50300:
errorData.append(
"At least Qt5 version 5.2 is required, found %s." % CONFIG.verQtString
"At least Qt5 version 5.3 is required, found %s." % CONFIG.verQtString
)
errorCode |= 8
if CONFIG.verPyQtValue < 50200:
if CONFIG.verPyQtValue < 50300:
errorData.append(
"At least PyQt5 version 5.2 is required, found %s." % CONFIG.verPyQtString
"At least PyQt5 version 5.3 is required, found %s." % CONFIG.verPyQtString
)
errorCode |= 16
-1
View File
@@ -377,7 +377,6 @@ class Config:
self.qtTrans = {}
langList = [
(self.qtLangPath, "qt"), # Qt 4.x
(self.qtLangPath, "qtbase"), # Qt 5.x
(self.nwLangPath, "qtbase"), # Alternative Qt 5.x
(self.nwLangPath, "nw"), # novelWriter
+1 -1
View File
@@ -583,7 +583,7 @@ class NWProject():
if errList:
self.makeAlert(errList, nwAlert.ERROR)
# Clean up old files
# Clean up no longer used files
self._deprecatedFiles()
# Update recent projects
+1 -1
View File
@@ -77,7 +77,7 @@ class ToMarkdown(Tokenizer):
self.FMT_D_B : "", self.FMT_D_E : "",
}
else:
# GitHub and novelWriter
# GitHub
mdTags = {
self.FMT_B_B : "**", self.FMT_B_E : "**",
self.FMT_I_B : "_", self.FMT_I_E : "_",
-1
View File
@@ -68,7 +68,6 @@ class NWErrorMessage(QDialog):
self.msgBody.setReadOnly(True)
self.btnBox = QDialogButtonBox(QDialogButtonBox.Close)
self.btnBox.button(QDialogButtonBox.Close).setText(self.tr("Close"))
self.btnBox.rejected.connect(self._doClose)
# Assemble
-1
View File
@@ -97,7 +97,6 @@ class GuiAbout(QDialog):
# OK Button
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.accepted.connect(self._doClose)
self.outerBox.addLayout(self.innerBox)
+1 -3
View File
@@ -858,10 +858,8 @@ class GuiBuildNovel(QDialog):
if not os.path.isdir(saveDir):
saveDir = self.mainConf.homePath
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Document As"), savePath, options=dlgOpt
self, self.tr("Save Document As"), savePath
)
if not savePath:
return False
-2
View File
@@ -500,8 +500,6 @@ class QuotesDialog(QDialog):
# Buttons
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doAccept)
self.buttonBox.rejected.connect(self._doReject)
+1 -1
View File
@@ -2050,7 +2050,7 @@ class GuiDocEditSearch(QFrame):
self._alertSearchValid(theRegEx.isValid())
return theRegEx
elif self.mainConf.verQtValue >= 50300:
else: # >= 50300 to < 51300
if self.isCaseSense:
rxOpt = Qt.CaseSensitive
else:
-2
View File
@@ -66,8 +66,6 @@ class GuiDocMerge(QDialog):
self.listBox.setMinimumHeight(self.mainConf.pxInt(180))
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doMerge)
self.buttonBox.rejected.connect(self._doClose)
-2
View File
@@ -82,8 +82,6 @@ class GuiDocSplit(QDialog):
self.splitLevel.currentIndexChanged.connect(self._populateList)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doSplit)
self.buttonBox.rejected.connect(self._doClose)
-2
View File
@@ -117,8 +117,6 @@ class GuiItemEditor(QDialog):
# Buttons
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
+2 -7
View File
@@ -70,8 +70,6 @@ class GuiPreferences(PagedDialog):
self.addTab(self.tabAuto, self.tr("Automation"))
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
self.addControls(self.buttonBox)
@@ -440,11 +438,8 @@ class GuiPreferencesProjects(QWidget):
if not os.path.isdir(currDir):
currDir = ""
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
newDir = QFileDialog.getExistingDirectory(
self, self.tr("Backup Directory"), currDir, options=dlgOpt
newDir = QFileDialog.getExistingDirectory(
self, self.tr("Backup Directory"), currDir, options=QFileDialog.ShowDirsOnly
)
if newDir:
self.backupPath = newDir
+2 -7
View File
@@ -127,8 +127,6 @@ class GuiProjectLoad(QDialog):
self.innerBox.addLayout(self.projectForm)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Open).setText(self.tr("Open"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doOpenRecent)
self.buttonBox.rejected.connect(self._doCancel)
@@ -188,13 +186,10 @@ class GuiProjectLoad(QDialog):
logger.verbose("GuiProjectLoad browse button clicked")
extFilter = [
self.tr("novelWriter Project File ({0})").format(nwFiles.PROJ_FILE),
self.tr("All files ({0})").format("*.*"),
self.tr("All files ({0})").format("*"),
]
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
projFile, _ = QFileDialog.getOpenFileName(
self, self.tr("Open novelWriter Project"), "",
filter=";;".join(extFilter), options=dlgOpt
self, self.tr("Open Project"), "", filter=";;".join(extFilter)
)
if projFile:
thePath = os.path.abspath(os.path.dirname(projFile))
+1 -4
View File
@@ -77,8 +77,6 @@ class GuiProjectSettings(PagedDialog):
self.addTab(self.tabReplace, self.tr("Auto-Replace"))
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
self.addControls(self.buttonBox)
@@ -330,8 +328,7 @@ class GuiProjectEditStatus(QWidget):
"""
if self.selColour is not None:
newCol = QColorDialog.getColor(
self.selColour, self, self.tr("Select Colour"),
QColorDialog.DontUseNativeDialog
self.selColour, self, self.tr("Select Colour")
)
if newCol.isValid():
self.selColour = newCol
+4 -7
View File
@@ -211,11 +211,8 @@ class ProjWizardFolderPage(QWizardPage):
if not os.path.isdir(lastPath):
lastPath = ""
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
projDir = QFileDialog.getExistingDirectory(
self, self.tr("Select Project Folder"), lastPath, options=dlgOpt
self, self.tr("Select Project Folder"), lastPath, options=QFileDialog.ShowDirsOnly
)
if projDir:
projName = self.field("projName")
@@ -412,9 +409,9 @@ class ProjWizardFinalPage(QWizardPage):
self.setTitle(self.tr("Finished"))
self.theText = QLabel(
"<p>{done}</p><p>{help}</p>".format(
done = self.tr("All done."),
help = self.tr("Press '{0}' to create the new project.").format(
"<p>%s</p><p>%s</p>" % (
self.tr("All done."),
self.tr("Press '{0}' to create the new project.").format(
self.tr("Done") if self.mainConf.osDarwin else self.tr("Finish")
)
)
-2
View File
@@ -90,8 +90,6 @@ class GuiWordList(QDialog):
self.editBox.addWidget(self.delButton, 0)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close)
self.buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Save"))
self.buttonBox.button(QDialogButtonBox.Close).setText(self.tr("Close"))
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
+1 -4
View File
@@ -259,7 +259,6 @@ class GuiWritingStats(QDialog):
self.buttonBox.rejected.connect(self._doClose)
self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close)
self.buttonBox.button(QDialogButtonBox.Close).setText(self.tr("Close"))
self.btnClose.setAutoDefault(False)
self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QDialogButtonBox.ActionRole)
@@ -369,10 +368,8 @@ class GuiWritingStats(QDialog):
fileName = "sessionStats.%s" % fileExt
savePath = os.path.join(saveDir, fileName)
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Data As"), savePath, options=dlgOpt
self, self.tr("Save Data As"), savePath, "%s (*.%s)" % (textFmt, fileExt)
)
if not savePath:
return False
+4 -28
View File
@@ -550,17 +550,9 @@ class GuiMain(QMainWindow):
logger.error("No project open")
return False
# If the project is new, it may not have a path, so we need one
if self.theProject.projPath is None:
projPath = self.selectProjectPath()
self.theProject.setProjectPath(projPath)
if self.theProject.projPath is None:
return False
self.treeView.saveTreeOrder()
self.theProject.saveProject(autoSave=autoSave)
self.theIndex.saveIndex()
if self.theProject.saveProject(autoSave=autoSave):
self.theIndex.saveIndex()
return True
@@ -705,13 +697,10 @@ class GuiMain(QMainWindow):
self.tr("Text files ({0})").format("*.txt"),
self.tr("Markdown files ({0})").format("*.md"),
self.tr("novelWriter files ({0})").format("*.nwd"),
self.tr("All files ({0})").format("*.*"),
self.tr("All files ({0})").format("*"),
]
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
loadFile, _ = QFileDialog.getOpenFileName(
self, self.tr("Import File"), lastPath,
options=dlgOpt, filter=";;".join(extFilter)
self, self.tr("Import File"), lastPath, filter=";;".join(extFilter)
)
if not loadFile:
return False
@@ -931,19 +920,6 @@ class GuiMain(QMainWindow):
# Main Dialogs
##
def selectProjectPath(self):
"""Select where to save project.
"""
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath = QFileDialog.getExistingDirectory(
self, self.tr("Save novelWriter Project"), "", options=dlgOpt
)
if projPath:
return projPath
return None
def showProjectLoadDialog(self):
"""Opens the projects dialog for selecting either existing
projects from a cache of recently opened projects, or provide a
+1 -12
View File
@@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import pytest
from PyQt5.QtCore import QItemSelectionModel
from PyQt5.QtWidgets import QListWidgetItem, QDialog, QFileDialog, QMessageBox
from PyQt5.QtWidgets import QListWidgetItem, QDialog, QMessageBox
from nw.gui.custom import QuotesDialog
@@ -59,14 +59,3 @@ def testGuiDialogs_Quotes(qtbot, monkeypatch, nwGUI, nwMinimal):
nwQuot.close()
# END Test testDialogs_Quotes
@pytest.mark.gui
def testGuiDialogs_Other(qtbot, monkeypatch, nwGUI, tmpDir):
"""Various other dialog tests.
"""
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: tmpDir)
assert nwGUI.selectProjectPath() == tmpDir
# qtbot.stopForInteraction()
# END Test testGuiDialogs_Other