From 2bc29c8b0a67a789570e440241eabb490c0bf17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Thu, 3 Oct 2024 11:09:42 +0200 Subject: [PATCH] Move newsletter stats translaton inside component The reason is, that translation strings outside weren't translated at all, even if they are present in .pot [MAILPOET-6262] --- .../listings/newsletter-stats/stats.tsx | 106 +++++++++--------- 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/mailpoet/assets/js/src/common/listings/newsletter-stats/stats.tsx b/mailpoet/assets/js/src/common/listings/newsletter-stats/stats.tsx index 6b18dc7809..e48a00bfa4 100644 --- a/mailpoet/assets/js/src/common/listings/newsletter-stats/stats.tsx +++ b/mailpoet/assets/js/src/common/listings/newsletter-stats/stats.tsx @@ -10,59 +10,7 @@ type StatsBadgeProps = { isInverted?: boolean; }; -const stats = { - opened: { - badgeRanges: [30, 10, 0], - badgeTypes: ['excellent', 'good', 'critical'], - tooltipText: { - // translators: Excellent open rate - excellent: __('above 30%', 'mailpoet'), - // translators: Good open rate - good: __('between 10 and 30%', 'mailpoet'), - // translators: Critical open rate - critical: __('under 10%', 'mailpoet'), - }, - }, - clicked: { - badgeRanges: [3, 1, 0], - badgeTypes: ['excellent', 'good', 'critical'], - tooltipText: { - // translators: Excellent click rate - excellent: __('above 3%', 'mailpoet'), - // translators: Good click rate - good: __('between 1 and 3%', 'mailpoet'), - // translators: Critical click rate - critical: __('under 1%', 'mailpoet'), - }, - }, - bounced: { - badgeRanges: [1.5, 0.5, 0], - badgeTypes: ['critical', 'good', 'excellent'], - tooltipText: { - // translators: Excellent bounce rate - excellent: __('below 0.5%', 'mailpoet'), - // translators: Good bounce rate - good: __('between 0.5% and 1.5%', 'mailpoet'), - // translators: Critical bounce rate - critical: __('above 1.5%', 'mailpoet'), - }, - }, - unsubscribed: { - badgeRanges: [0.7, 0.3, 0], - badgeTypes: ['critical', 'good', 'excellent'], - tooltipText: { - // translators: Excellent unsubscribe rate - excellent: __('Below 0.3%', 'mailpoet'), - // translators: Good unsubscribe rate - good: __('between 0.3% and 0.7%', 'mailpoet'), - // translators: Critical unsubscribe rate - critical: __('above 0.7%', 'mailpoet'), - }, - }, -}; - -export const getBadgeType = (statName, rate) => { - const stat = stats[statName] || null; +export const getBadgeType = (stat, rate) => { if (!stat) { return null; } @@ -96,8 +44,58 @@ function StatsBadge(props: StatsBadgeProps) { tooltipTitle: __('Something to improve.', 'mailpoet'), }, }; + const stats = { + opened: { + badgeRanges: [30, 10, 0], + badgeTypes: ['excellent', 'good', 'critical'], + tooltipText: { + // translators: Excellent open rate + excellent: __('above 30%', 'mailpoet'), + // translators: Good open rate + good: __('between 10 and 30%', 'mailpoet'), + // translators: Critical open rate + critical: __('under 10%', 'mailpoet'), + }, + }, + clicked: { + badgeRanges: [3, 1, 0], + badgeTypes: ['excellent', 'good', 'critical'], + tooltipText: { + // translators: Excellent click rate + excellent: __('above 3%', 'mailpoet'), + // translators: Good click rate + good: __('between 1 and 3%', 'mailpoet'), + // translators: Critical click rate + critical: __('under 1%', 'mailpoet'), + }, + }, + bounced: { + badgeRanges: [1.5, 0.5, 0], + badgeTypes: ['critical', 'good', 'excellent'], + tooltipText: { + // translators: Excellent bounce rate + excellent: __('below 0.5%', 'mailpoet'), + // translators: Good bounce rate + good: __('between 0.5% and 1.5%', 'mailpoet'), + // translators: Critical bounce rate + critical: __('above 1.5%', 'mailpoet'), + }, + }, + unsubscribed: { + badgeRanges: [0.7, 0.3, 0], + badgeTypes: ['critical', 'good', 'excellent'], + tooltipText: { + // translators: Excellent unsubscribe rate + excellent: __('Below 0.3%', 'mailpoet'), + // translators: Good unsubscribe rate + good: __('between 0.3% and 0.7%', 'mailpoet'), + // translators: Critical unsubscribe rate + critical: __('above 0.7%', 'mailpoet'), + }, + }, + }; - const badgeType = getBadgeType(props.stat, props.rate); + const badgeType = getBadgeType(stats[props.stat], props.rate); const badge = badges[badgeType] || null; if (!badge) { return null;