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.
This commit is contained in:
parent
9e5b909070
commit
879ca0b72b
@ -166,8 +166,8 @@ from revlog where id > ? """+lim, (self.col.sched.dayCutoff-86400)*1000)
|
||||
def bold(s):
|
||||
return "<b>"+str(s)+"</b>"
|
||||
msgp1 = ngettext("<!--studied-->%d card", "<!--studied-->%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 += "<br>" + _("Again count: %s") % bold(failed)
|
||||
if cards:
|
||||
|
@ -37,13 +37,13 @@ timeTable = {
|
||||
"seconds": lambda n: ngettext("%s second", "%s seconds", n),
|
||||
}
|
||||
|
||||
afterTimeTable = {
|
||||
"years": lambda n: ngettext("%s year<!--after-->", "%s years<!--after-->", n),
|
||||
"months": lambda n: ngettext("%s month<!--after-->", "%s months<!--after-->", n),
|
||||
"days": lambda n: ngettext("%s day<!--after-->", "%s days<!--after-->", n),
|
||||
"hours": lambda n: ngettext("%s hour<!--after-->", "%s hours<!--after-->", n),
|
||||
"minutes": lambda n: ngettext("%s minute<!--after-->", "%s minutes<!--after-->", n),
|
||||
"seconds": lambda n: ngettext("%s second<!--after-->", "%s seconds<!--after-->", 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}
|
||||
|
@ -106,8 +106,8 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||
cards = cards or 0
|
||||
thetime = thetime or 0
|
||||
msgp1 = ngettext("<!--studied-->%d card", "<!--studied-->%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):
|
||||
|
Loading…
Reference in New Issue
Block a user