From be8f98f6c7ade642d0aef928ee35c8db545b8ee2 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 17 Feb 2021 19:10:50 +0100 Subject: [PATCH] Add more translations --- novelWriter.pro | 1 + nw/common.py | 57 +++++++++++++++++++++++++++++++----------- nw/gui/preferences.py | 3 +-- nw/gui/projsettings.py | 9 ++++--- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/novelWriter.pro b/novelWriter.pro index a21751e1..82f33934 100644 --- a/novelWriter.pro +++ b/novelWriter.pro @@ -26,6 +26,7 @@ SOURCES += \ nw/gui/theme.py \ nw/gui/wordlist.py \ nw/gui/writingstats.py \ + nw/common.py \ nw/error.py \ nw/guimain.py diff --git a/nw/common.py b/nw/common.py index 4464f287..e4015563 100644 --- a/nw/common.py +++ b/nw/common.py @@ -29,6 +29,7 @@ import logging from datetime import datetime from PyQt5.QtWidgets import qApp +from PyQt5.QtCore import QCoreApplication from nw.constants import ( nwConst, nwUnicode, nwItemClass, nwItemType, nwItemLayout @@ -267,33 +268,61 @@ def fuzzyTime(secDiff): """Converts a time difference in seconds into a fuzzy time string. """ if secDiff < 0: - return "in the future" + return QCoreApplication.translate( + "Common", "in the future" + ) elif secDiff < 30: - return "just now" + return QCoreApplication.translate( + "Common", "just now" + ) elif secDiff < 90: - return "a minute ago" + return QCoreApplication.translate( + "Common", "a minute ago" + ) elif secDiff < 3300: # 55 minutes - return "%d minutes ago" % int(round(secDiff/60)) + return QCoreApplication.translate( + "Common", "{0} minutes ago").format(int(round(secDiff/60)) + ) elif secDiff < 5400: # 90 minutes - return "an hour ago" + return QCoreApplication.translate( + "Common", "an hour ago" + ) elif secDiff < 84600: # 23.5 hours - return "%d hours ago" % int(round(secDiff/3600)) + return QCoreApplication.translate( + "Common", "{0} hours ago").format(int(round(secDiff/3600)) + ) elif secDiff < 129600: # 1.5 days - return "a day ago" + return QCoreApplication.translate( + "Common", "a day ago" + ) elif secDiff < 561600: # 6.5 days - return "%d days ago" % int(round(secDiff/86400)) + return QCoreApplication.translate( + "Common", "{0} days ago").format(int(round(secDiff/86400)) + ) elif secDiff < 907200: # 10.5 days - return "a week ago" + return QCoreApplication.translate( + "Common", "a week ago" + ) elif secDiff < 2419200: # 28 days - return "%d weeks ago" % int(round(secDiff/604800)) + return QCoreApplication.translate( + "Common", "{0} weeks ago").format(int(round(secDiff/604800)) + ) elif secDiff < 3888000: # 45 days - return "a month ago" + return QCoreApplication.translate( + "Common", "a month ago" + ) elif secDiff < 29808000: # 345 days - return "%d months ago" % int(round(secDiff/2592000)) + return QCoreApplication.translate( + "Common", "{0} months ago").format(int(round(secDiff/2592000)) + ) elif secDiff < 47336400: # 1.5 years - return "a year ago" + return QCoreApplication.translate( + "Common", "a year ago" + ) else: - return "%d years ago" % int(round(secDiff/31557600)) + return QCoreApplication.translate( + "Common", "{0} years ago").format(int(round(secDiff/31557600)) + ) def makeFileNameSafe(theText): """Returns a filename safe version of the text. diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index a919b120..09a0c3a9 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -828,8 +828,7 @@ class GuiPreferencesEditor(QWidget): for spTag, spProv in theDict.listDictionaries(): qLocal = QLocale(spTag) spLang = qLocal.nativeLanguageName().title() - spName = qLocal.bcp47Name() - self.spellLangList.addItem("%s (%s) [%s]" % (spLang, spName, spProv), spTag) + self.spellLangList.addItem("%s [%s]" % (spLang, spProv), spTag) spellIdx = self.spellLangList.findData(self.mainConf.spellLanguage) if spellIdx != -1: diff --git a/nw/gui/projsettings.py b/nw/gui/projsettings.py index b7e13bbb..c09cbfdb 100644 --- a/nw/gui/projsettings.py +++ b/nw/gui/projsettings.py @@ -27,7 +27,7 @@ along with this program. If not, see . import nw import logging -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QLocale from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush from PyQt5.QtWidgets import ( QHBoxLayout, QVBoxLayout, QLineEdit, QPlainTextEdit, QLabel, QWidget, @@ -207,11 +207,14 @@ class GuiProjectEditMain(QWidget): ) self.spellLang = QComboBox(self) + self.spellLang.setFixedWidth(xW) theDict = self.theParent.docEditor.theDict self.spellLang.addItem(self.tr("Default"), "None") if theDict is not None: - for spTag, spName in theDict.listDictionaries(): - self.spellLang.addItem(spName, spTag) + for spTag, spProv in theDict.listDictionaries(): + qLocal = QLocale(spTag) + spLang = qLocal.nativeLanguageName().title() + self.spellLang.addItem("%s [%s]" % (spLang, spProv), spTag) self.mainForm.addRow( self.tr("Spell check language"),