From 8d5c4ecc3398611764a4459c0e92f0fb90edd90f Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Fri, 3 Jan 2025 11:20:29 +1000 Subject: [PATCH] FIX: Dashboard report change tooltip was not translated (#30541) Use i18n in the JS code instead of concatenating English strings. c.f. https://meta.discourse.org/t/titles-on-graphs-in-community-health-dashboard-are-not-localized/302776/8?u=martin --- .../javascripts/admin/addon/models/report.js | 17 +++++++++++++---- config/locales/client.en.yml | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/addon/models/report.js b/app/assets/javascripts/admin/addon/models/report.js index 34d268fac8d..868cc28e441 100644 --- a/app/assets/javascripts/admin/addon/models/report.js +++ b/app/assets/javascripts/admin/addon/models/report.js @@ -407,12 +407,21 @@ export default class Report extends EmberObject { changeTitle(valAtT1, valAtT2, prevPeriodString) { const change = this.percentChangeString(valAtT1, valAtT2); - let title = ""; + const title = []; if (change) { - title += `${change} change. `; + title.push( + i18n("admin.dashboard.reports.percent_change_tooltip", { + percent: change, + }) + ); } - title += `Was ${number(valAtT1)} ${prevPeriodString}.`; - return title; + title.push( + i18n("admin.dashboard.reports.percent_change_tooltip_previous_value", { + previousValue: number(valAtT1), + previousPeriod: prevPeriodString, + }) + ); + return title.join(" "); } @discourseComputed("yesterdayCount") diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d2d25f39810..ad98210d3cd 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5217,6 +5217,8 @@ 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}." today: "Today" yesterday: "Yesterday" last_7_days: "Last 7"