From 2e704660d65c4d85c1bab0396a89a3fd6c7b4fb0 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 26 Mar 2021 19:24:48 +1000 Subject: [PATCH] update remaining TR references in ts/ --- ts/lib/time.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/ts/lib/time.ts b/ts/lib/time.ts index eae156fa3..61e05fe26 100644 --- a/ts/lib/time.ts +++ b/ts/lib/time.ts @@ -90,36 +90,40 @@ export function studiedToday(i18n: I18n, cards: number, secs: number): string { }); } -function i18nKeyForUnit(i18n: I18n, unit: TimespanUnit, short: boolean): number { +function i18nFuncForUnit( + i18n: I18n, + unit: TimespanUnit, + short: boolean +): ({ amount: number }) => string { if (short) { switch (unit) { case TimespanUnit.Seconds: - return i18n.TR.STATISTICS_ELAPSED_TIME_SECONDS; + return i18n.statisticsElapsedTimeSeconds; case TimespanUnit.Minutes: - return i18n.TR.STATISTICS_ELAPSED_TIME_MINUTES; + return i18n.statisticsElapsedTimeMinutes; case TimespanUnit.Hours: - return i18n.TR.STATISTICS_ELAPSED_TIME_HOURS; + return i18n.statisticsElapsedTimeHours; case TimespanUnit.Days: - return i18n.TR.STATISTICS_ELAPSED_TIME_DAYS; + return i18n.statisticsElapsedTimeDays; case TimespanUnit.Months: - return i18n.TR.STATISTICS_ELAPSED_TIME_MONTHS; + return i18n.statisticsElapsedTimeMonths; case TimespanUnit.Years: - return i18n.TR.STATISTICS_ELAPSED_TIME_YEARS; + return i18n.statisticsElapsedTimeYears; } } else { switch (unit) { case TimespanUnit.Seconds: - return i18n.TR.SCHEDULING_TIME_SPAN_SECONDS; + return i18n.schedulingTimeSpanSeconds; case TimespanUnit.Minutes: - return i18n.TR.SCHEDULING_TIME_SPAN_MINUTES; + return i18n.schedulingTimeSpanMinutes; case TimespanUnit.Hours: - return i18n.TR.SCHEDULING_TIME_SPAN_HOURS; + return i18n.schedulingTimeSpanHours; case TimespanUnit.Days: - return i18n.TR.SCHEDULING_TIME_SPAN_DAYS; + return i18n.schedulingTimeSpanDays; case TimespanUnit.Months: - return i18n.TR.SCHEDULING_TIME_SPAN_MONTHS; + return i18n.schedulingTimeSpanMonths; case TimespanUnit.Years: - return i18n.TR.SCHEDULING_TIME_SPAN_YEARS; + return i18n.schedulingTimeSpanYears; } } } @@ -131,8 +135,7 @@ function i18nKeyForUnit(i18n: I18n, unit: TimespanUnit, short: boolean): number export function timeSpan(i18n: I18n, seconds: number, short = false): string { const unit = naturalUnit(seconds); const amount = unitAmount(unit, seconds); - const key = i18nKeyForUnit(i18n, unit, short); - return i18n.tr(key, { amount }); + return i18nFuncForUnit(i18n, unit, short).call(i18n, { amount }); } export function dayLabel(i18n: I18n, daysStart: number, daysEnd: number): string {