From d8692faf00d07c81aa76bb9a9bc9a6a9f6e46797 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 7 Jan 2025 09:49:34 +1000 Subject: [PATCH] UX: More translations for admin dashboard (#30570) Followup 8d5c4ecc3398611764a4459c0e92f0fb90edd90f Implement review suggestions from https://github.com/discourse/discourse/pull/30541 after merge, and also fix other hardcoded strings on this dashboard. --- .../javascripts/admin/addon/models/report.js | 21 +++++++++++-------- config/locales/client.en.yml | 11 +++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/admin/addon/models/report.js b/app/assets/javascripts/admin/addon/models/report.js index 868cc28e441..c77f6222b2b 100644 --- a/app/assets/javascripts/admin/addon/models/report.js +++ b/app/assets/javascripts/admin/addon/models/report.js @@ -376,9 +376,9 @@ export default class Report extends EmberObject { if (isNaN(change) || !isFinite(change)) { return null; } else if (change > 0) { - return "+" + change.toFixed(0) + "%"; + return `+${i18n("js.number.percent", { count: change.toFixed(0) })}`; } else { - return change.toFixed(0) + "%"; + return `${i18n("js.number.percent", { count: change.toFixed(0) })}`; } } @@ -416,17 +416,20 @@ export default class Report extends EmberObject { ); } title.push( - i18n("admin.dashboard.reports.percent_change_tooltip_previous_value", { - previousValue: number(valAtT1), - previousPeriod: prevPeriodString, - }) + i18n( + `admin.dashboard.reports.percent_change_tooltip_previous_value.${prevPeriodString}`, + { + count: valAtT1, + previousValue: number(valAtT1), + } + ) ); return title.join(" "); } @discourseComputed("yesterdayCount") yesterdayCountTitle(yesterdayCount) { - return this.changeTitle(this.valueAt(2), yesterdayCount, "two days ago"); + return this.changeTitle(this.valueAt(2), yesterdayCount, "yesterday"); } @discourseComputed("lastSevenDaysCount") @@ -434,7 +437,7 @@ export default class Report extends EmberObject { return this.changeTitle( this.valueFor(8, 14), lastSevenDaysCount, - "two weeks ago" + "two_weeks_ago" ); } @@ -448,7 +451,7 @@ export default class Report extends EmberObject { return this.changeTitle( prev30Days ?? prev_period, lastThirtyDaysCount, - "in the previous 30 day period" + "thirty_days_ago" ); } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 488435ed6e3..1c5f9520b5e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5236,7 +5236,16 @@ en: reports: trend_title: "%{percent} change. Currently %{current}, was %{prev} in previous period." percent_change_tooltip: "%{percent} change." - percent_change_tooltip_previous_value: "Was %{previousValue} %{previousPeriod}." + percent_change_tooltip_previous_value: + yesterday: + one: "Was %{count} two days ago." + other: "Was %{count} two days ago." + two_weeks_ago: + one: "Was %{count} two weeks ago." + other: "Was %{count} two weeks ago." + thirty_days_ago: + one: "Was %{count} in the previous 30 day period." + other: "Was %{count} in the previous 30 day period." today: "Today" yesterday: "Yesterday" last_7_days: "Last 7"