From 409c0ddf850fc5537d13150a6a009bbf1174ee7a Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 28 May 2018 20:03:05 +0200 Subject: [PATCH] UX: localizes titles in dashboard table reports --- .../javascripts/admin/models/report.js.es6 | 19 ++++++++++++++----- config/locales/client.en.yml | 5 +++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/models/report.js.es6 b/app/assets/javascripts/admin/models/report.js.es6 index 80c160a8d90..aa61c511056 100644 --- a/app/assets/javascripts/admin/models/report.js.es6 +++ b/app/assets/javascripts/admin/models/report.js.es6 @@ -170,24 +170,33 @@ const Report = Discourse.Model.extend({ changeTitle(valAtT1, valAtT2, prevPeriodString) { const change = this.percentChangeString(valAtT1, valAtT2); let title = ""; - if (change) { title += `${change} change. `; } - title += `Was ${number(valAtT1)} ${prevPeriodString}.`; + + if (change) { + const changeString = I18n.t("admin.dashboard.reports.percent_change", { percent: change }); + title += `${changeString} `; + } + + title += I18n.t("admin.dashboard.reports.previous_value", { + previousValue: number(valAtT1), + when: prevPeriodString + }); + return title; }, @computed("yesterdayCount") yesterdayCountTitle(yesterdayCount) { - return this.changeTitle(this.valueAt(2), yesterdayCount, "two days ago"); + return this.changeTitle(this.valueAt(2), yesterdayCount, I18n.t("admin.dashboard.reports.two_days_ago")); }, @computed("lastSevenDaysCount") sevenDaysCountTitle(lastSevenDaysCount) { - return this.changeTitle(this.valueFor(8, 14), lastSevenDaysCount, "two weeks ago"); + return this.changeTitle(this.valueFor(8, 14), lastSevenDaysCount, I18n.t("admin.dashboard.reports.two_weeks_ago")); }, @computed("prev30Days", "lastThirtyDaysCount") thirtyDaysCountTitle(prev30Days, lastThirtyDaysCount) { - return this.changeTitle(prev30Days, lastThirtyDaysCount, "in the previous 30 day period"); + return this.changeTitle(prev30Days, lastThirtyDaysCount, I18n.t("admin.dashboard.reports.previous_30_days_period")); }, @computed("data") diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 53520a97d0c..b1cff2680e1 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2767,6 +2767,11 @@ en: end_date: "End Date" groups: "All groups" disabled: "This report is disabled" + percent_change: "%{percent} change." + previous_value: "Was %{previousValue} %{when}." + two_days_ago: "two days ago" + two_weeks_ago: "two weeks ago" + previous_30_days_period: "in the previous 30 days period" trending_search: more: 'Search logs' disabled: 'Trending search report is disabled. Enable log search queries to collect data.'