Add more translations

This commit is contained in:
Veronica K. B. Olsen
2021-02-17 19:10:50 +01:00
parent 5a685474ff
commit be8f98f6c7
4 changed files with 51 additions and 19 deletions
+1
View File
@@ -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
+43 -14
View File
@@ -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.
+1 -2
View File
@@ -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:
+6 -3
View File
@@ -27,7 +27,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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"),