From 879ca0b72bae21ef6240039ea4d8007cd4a95bcb Mon Sep 17 00:00:00 2001 From: Piotr Kubowicz Date: Thu, 30 Nov 2017 20:03:51 +0100 Subject: [PATCH] Allow to better translate "in x minutes" "There is 1 minute" and "in 1 minute" need to be translated differently in Slavic languages. Additionally remove unused afterTimeTable. --- anki/stats.py | 4 ++-- anki/utils.py | 20 ++++++++++---------- aqt/deckbrowser.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/anki/stats.py b/anki/stats.py index e1b6a4a68..a55649410 100644 --- a/anki/stats.py +++ b/anki/stats.py @@ -166,8 +166,8 @@ from revlog where id > ? """+lim, (self.col.sched.dayCutoff-86400)*1000) def bold(s): return ""+str(s)+"" msgp1 = ngettext("%d card", "%d cards", cards) % cards - b += _("Studied %(a)s in %(b)s today.") % dict( - a=bold(msgp1), b=bold(fmtTimeSpan(thetime, unit=1))) + b += _("Studied %(a)s %(b)s today.") % dict( + a=bold(msgp1), b=bold(fmtTimeSpan(thetime, unit=1, inTime=True))) # again/pass count b += "
" + _("Again count: %s") % bold(failed) if cards: diff --git a/anki/utils.py b/anki/utils.py index 39afc1c7c..7e534c994 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -37,13 +37,13 @@ timeTable = { "seconds": lambda n: ngettext("%s second", "%s seconds", n), } -afterTimeTable = { - "years": lambda n: ngettext("%s year", "%s years", n), - "months": lambda n: ngettext("%s month", "%s months", n), - "days": lambda n: ngettext("%s day", "%s days", n), - "hours": lambda n: ngettext("%s hour", "%s hours", n), - "minutes": lambda n: ngettext("%s minute", "%s minutes", n), - "seconds": lambda n: ngettext("%s second", "%s seconds", n), +inTimeTable = { + "years": lambda n: ngettext("in %s year", "in %s years", n), + "months": lambda n: ngettext("in %s month", "in %s months", n), + "days": lambda n: ngettext("in %s day", "in %s days", n), + "hours": lambda n: ngettext("in %s hour", "in %s hours", n), + "minutes": lambda n: ngettext("in %s minute", "in %s minutes", n), + "seconds": lambda n: ngettext("in %s second", "in %s seconds", n), } def shortTimeFmt(type): @@ -56,7 +56,7 @@ def shortTimeFmt(type): "seconds": _("%ss"), }[type] -def fmtTimeSpan(time, pad=0, point=0, short=False, after=False, unit=99): +def fmtTimeSpan(time, pad=0, point=0, short=False, inTime=False, unit=99): "Return a string representing a time span (eg '2 days')." (type, point) = optimalPeriod(time, point, unit) time = convertSecondsTo(time, type) @@ -65,8 +65,8 @@ def fmtTimeSpan(time, pad=0, point=0, short=False, after=False, unit=99): if short: fmt = shortTimeFmt(type) else: - if after: - fmt = afterTimeTable[type](_pluralCount(time, point)) + if inTime: + fmt = inTimeTable[type](_pluralCount(time, point)) else: fmt = timeTable[type](_pluralCount(time, point)) timestr = "%(a)d.%(b)df" % {'a': pad, 'b': point} diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index d3b3dd3e5..8447e2a25 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -106,8 +106,8 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000) cards = cards or 0 thetime = thetime or 0 msgp1 = ngettext("%d card", "%d cards", cards) % cards - buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1, - b=fmtTimeSpan(thetime, unit=1)) + buf = _("Studied %(a)s %(b)s today.") % dict(a=msgp1, + b=fmtTimeSpan(thetime, unit=1, inTime=True)) return buf def _countWarn(self):