From 8e39ebb2f5d3a334dfea9e0e7c7cabf46d5e5414 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 20 Jan 2021 21:49:01 +0100 Subject: [PATCH] Make weekday labels localizable --- ftl/core/statistics.ftl | 7 +++++++ ts/graphs/CalendarGraph.svelte | 2 +- ts/graphs/calendar.ts | 12 ++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ftl/core/statistics.ftl b/ftl/core/statistics.ftl index 0b5fc5eb5..5c4353717 100644 --- a/ftl/core/statistics.ftl +++ b/ftl/core/statistics.ftl @@ -156,6 +156,13 @@ statistics-hours-subtitle = Review success rate for each hour of the day. # shown when graph is empty statistics-no-data = NO DATA statistics-calendar-title = Calendar +statistics-calendar-label-sunday = S +statistics-calendar-label-monday = M +statistics-calendar-label-tuesday = T +statistics-calendar-label-wednesday = W +statistics-calendar-label-thursday = T +statistics-calendar-label-friday = F +statistics-calendar-label-saturday = S ## An amount of elapsed time, used in the graphs to show the amount of ## time spent studying. For example, English would show "5s" for 5 seconds, diff --git a/ts/graphs/CalendarGraph.svelte b/ts/graphs/CalendarGraph.svelte index c11606c09..910ed6565 100644 --- a/ts/graphs/CalendarGraph.svelte +++ b/ts/graphs/CalendarGraph.svelte @@ -25,7 +25,7 @@ let targetYear = maxYear; $: if (sourceData) { - graphData = gatherData(sourceData); + graphData = gatherData(sourceData, i18n); } $: { diff --git a/ts/graphs/calendar.ts b/ts/graphs/calendar.ts index f9ddc55bf..3afbc02f2 100644 --- a/ts/graphs/calendar.ts +++ b/ts/graphs/calendar.ts @@ -41,7 +41,7 @@ interface DayDatum { date: Date; } -export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { +export function gatherData(data: pb.BackendProto.GraphsOut, i18n: I18n): GraphData { const reviewCount = new Map(); for (const review of data.revlog as pb.BackendProto.RevlogEntry[]) { @@ -64,7 +64,15 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { ? timeSaturday : timeSunday; - const weekdayLabels = ["S", "M", "T", "W", "T", "F", "S"]; + const weekdayLabels = [ + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_SUNDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_MONDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_TUESDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_WEDNESDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_THURSDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_FRIDAY), + i18n.tr(i18n.TR.STATISTICS_CALENDAR_LABEL_SATURDAY), + ]; for (let i = 0; i < data.firstWeekday; i++) { const shifted = weekdayLabels.shift() as string;