From f3c07e27d918edd65907f347035467a783766a31 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Tue, 28 May 2019 22:10:51 +0300 Subject: [PATCH] FIX: correct translations for logs error rate notice (#7622) The problem here is that hour and minute were passed to the %{duration} variable which made them impossible to translate in other languages. I wonder if it's worth having 2 almost identical translations just for "reached" and "exceeded"? Perhaps we could combine them in one copy? --- .../discourse/services/logs-notice.js.es6 | 17 ++++++----------- config/locales/client.en.yml | 9 ++++----- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/services/logs-notice.js.es6 b/app/assets/javascripts/discourse/services/logs-notice.js.es6 index 3dc12315bcd..f70e0219927 100644 --- a/app/assets/javascripts/discourse/services/logs-notice.js.es6 +++ b/app/assets/javascripts/discourse/services/logs-notice.js.es6 @@ -20,7 +20,7 @@ const LogsNotice = Ember.Object.extend({ this.messageBus.subscribe("/logs_error_rate_exceeded", data => { const duration = data.duration; const rate = data.rate; - var siteSettingLimit = 0; + let siteSettingLimit = 0; if (duration === "minute") { siteSettingLimit = this.siteSettings.alert_admins_if_errors_per_minute; @@ -28,22 +28,17 @@ const LogsNotice = Ember.Object.extend({ siteSettingLimit = this.siteSettings.alert_admins_if_errors_per_hour; } - var translationKey = rate === siteSettingLimit ? "reached" : "exceeded"; + let translationKey = rate === siteSettingLimit ? "reached" : "exceeded"; + translationKey += `_${duration}_MF`; this.set( "text", - I18n.t(`logs_error_rate_notice.${translationKey}`, { + I18n.messageFormat(`logs_error_rate_notice.${translationKey}`, { relativeAge: autoUpdatingRelativeAge( new Date(data.publish_at * 1000) ), - siteSettingRate: I18n.t("logs_error_rate_notice.rate", { - count: siteSettingLimit, - duration: duration - }), - rate: I18n.t("logs_error_rate_notice.rate", { - count: rate, - duration: duration - }), + rate, + limit: siteSettingLimit, url: Discourse.getURL("/logs") }) ); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 9a92810b59f..844b204ac7d 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1273,11 +1273,10 @@ en: too_few_topics_notice: "Let's get this discussion started! There are currently %{currentTopics} / %{requiredTopics} topics. New visitors need some conversations to read and respond to." too_few_posts_notice: "Let's get this discussion started! There are currently %{currentPosts} / %{requiredPosts} posts. New visitors need some conversations to read and respond to." logs_error_rate_notice: - reached: "%{relativeAge}%{rate} reached site setting limit of %{siteSettingRate}." - exceeded: "%{relativeAge}%{rate} exceeds site setting limit of %{siteSettingRate}." - rate: - one: "%{count} error/%{duration}" - other: "%{count} errors/%{duration}" + reached_hour_MF: "{relativeAge}{rate, plural, one {# error/hour} other {# errors/hour}} reached site setting limit of {limit, plural, one {# error/hour} other {# errors/hour}}." + reached_minute_MF: "{relativeAge}{rate, plural, one {# error/minute} other {# errors/minute}} reached site setting limit of {limit, plural, one {# error/minute} other {# errors/minute}}." + exceeded_hour_MF: "{relativeAge}{rate, plural, one {# error/hour} other {# errors/hour}} exceeded site setting limit of {limit, plural, one {# error/hour} other {# errors/hour}}." + exceeded_minute_MF: "{relativeAge}{rate, plural, one {# error/minute} other {# errors/minute}} exceeded site setting limit of {limit, plural, one {# error/minute} other {# errors/minute}}." learn_more: "learn more..."