Make email badge strings reusable by using placeholders

[MAILPOET-6312]
This commit is contained in:
 Ján Mikláš
2024-11-08 09:55:42 +01:00
committed by Aschepikov
parent 264bfd6ce7
commit f6befec2a2

View File

@@ -1,4 +1,4 @@
import { __ } from '@wordpress/i18n'; import { __, sprintf } from '@wordpress/i18n';
import { PlacesType } from 'react-tooltip'; import { PlacesType } from 'react-tooltip';
import { Badge } from './badge'; import { Badge } from './badge';
@@ -15,48 +15,48 @@ const getStats = () => ({
badgeRanges: [30, 10, 0], badgeRanges: [30, 10, 0],
badgeTypes: ['excellent', 'good', 'critical'], badgeTypes: ['excellent', 'good', 'critical'],
tooltipText: { tooltipText: {
// translators: Excellent open rate // translators: Shows a percentage range, "above 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
excellent: __('above 30%', 'mailpoet'), excellent: sprintf(__('above %s%%', 'mailpoet'), 30),
// translators: Good open rate // translators: Shows a percentage range, "between 10% and 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
good: __('between 10 and 30%', 'mailpoet'), good: sprintf(__('between %s%% and %s%%', 'mailpoet'), 10, 30),
// translators: Critical open rate // translators: Shows a percentage range, "below 10%". Used in contexts like open, click, bounce, or unsubscribe rates.
critical: __('under 10%', 'mailpoet'), critical: sprintf(__('below %s%%', 'mailpoet'), 10),
}, },
}, },
clicked: { clicked: {
badgeRanges: [3, 1, 0], badgeRanges: [3, 1, 0],
badgeTypes: ['excellent', 'good', 'critical'], badgeTypes: ['excellent', 'good', 'critical'],
tooltipText: { tooltipText: {
// translators: Excellent click rate // translators: Shows a percentage range, "above 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
excellent: __('above 3%', 'mailpoet'), excellent: sprintf(__('above %s%%', 'mailpoet'), 3),
// translators: Good click rate // translators: Shows a percentage range, "between 10% and 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
good: __('between 1 and 3%', 'mailpoet'), good: sprintf(__('between %s%% and %s%%', 'mailpoet'), 1, 3),
// translators: Critical click rate // translators: Shows a percentage range, "below 10%". Used in contexts like open, click, bounce, or unsubscribe rates.
critical: __('under 1%', 'mailpoet'), critical: sprintf(__('below %s%%', 'mailpoet'), 1),
}, },
}, },
bounced: { bounced: {
badgeRanges: [1.5, 0.5, 0], badgeRanges: [1.5, 0.5, 0],
badgeTypes: ['critical', 'good', 'excellent'], badgeTypes: ['critical', 'good', 'excellent'],
tooltipText: { tooltipText: {
// translators: Excellent bounce rate // translators: Shows a percentage range, "below 10%". Used in contexts like open, click, bounce, or unsubscribe rates.
excellent: __('below 0.5%', 'mailpoet'), excellent: sprintf(__('below %s%%', 'mailpoet'), 0.5),
// translators: Good bounce rate // translators: Shows a percentage range, "between 10% and 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
good: __('between 0.5% and 1.5%', 'mailpoet'), good: sprintf(__('between %s%% and %s%%', 'mailpoet'), 0.5, 1.5),
// translators: Critical bounce rate // translators: Shows a percentage range, "above 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
critical: __('above 1.5%', 'mailpoet'), critical: sprintf(__('above %s%%', 'mailpoet'), 1.5),
}, },
}, },
unsubscribed: { unsubscribed: {
badgeRanges: [0.7, 0.3, 0], badgeRanges: [0.7, 0.3, 0],
badgeTypes: ['critical', 'good', 'excellent'], badgeTypes: ['critical', 'good', 'excellent'],
tooltipText: { tooltipText: {
// translators: Excellent unsubscribe rate // translators: Shows a percentage range, "below 10%". Used in contexts like open, click, bounce, or unsubscribe rates.
excellent: __('Below 0.3%', 'mailpoet'), excellent: sprintf(__('below %s%%', 'mailpoet'), 0.3),
// translators: Good unsubscribe rate // translators: Shows a percentage range, "between 10% and 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
good: __('between 0.3% and 0.7%', 'mailpoet'), good: sprintf(__('between %s%% and %s%%', 'mailpoet'), 0.3, 0.7),
// translators: Critical unsubscribe rate // translators: Shows a percentage range, "above 30%". Used in contexts like open, click, bounce, or unsubscribe rates.
critical: __('above 0.7%', 'mailpoet'), critical: sprintf(__('above %s%%', 'mailpoet'), 0.7),
}, },
}, },
}); });