mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
defer i18n lookup of shortTimeTable
This commit is contained in:
parent
df98e8609e
commit
087533fbc5
1 changed files with 4 additions and 3 deletions
|
@ -43,14 +43,15 @@ afterTimeTable = {
|
||||||
"seconds": lambda n: ngettext("%s second<!--after-->", "%s seconds<!--after-->", n),
|
"seconds": lambda n: ngettext("%s second<!--after-->", "%s seconds<!--after-->", n),
|
||||||
}
|
}
|
||||||
|
|
||||||
shortTimeTable = {
|
def shortTimeFmt(type):
|
||||||
|
return {
|
||||||
"years": _("%sy"),
|
"years": _("%sy"),
|
||||||
"months": _("%smo"),
|
"months": _("%smo"),
|
||||||
"days": _("%sd"),
|
"days": _("%sd"),
|
||||||
"hours": _("%sh"),
|
"hours": _("%sh"),
|
||||||
"minutes": _("%sm"),
|
"minutes": _("%sm"),
|
||||||
"seconds": _("%ss"),
|
"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, after=False, unit=99):
|
||||||
"Return a string representing a time span (eg '2 days')."
|
"Return a string representing a time span (eg '2 days')."
|
||||||
|
@ -59,7 +60,7 @@ def fmtTimeSpan(time, pad=0, point=0, short=False, after=False, unit=99):
|
||||||
if not point:
|
if not point:
|
||||||
time = math.floor(time)
|
time = math.floor(time)
|
||||||
if short:
|
if short:
|
||||||
fmt = shortTimeTable[type]
|
fmt = shortTimeFmt(type)
|
||||||
else:
|
else:
|
||||||
if after:
|
if after:
|
||||||
fmt = afterTimeTable[type](_pluralCount(time, point))
|
fmt = afterTimeTable[type](_pluralCount(time, point))
|
||||||
|
|
Loading…
Reference in a new issue