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]
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
6a8a209d11
commit
2bc29c8b0a
@ -10,59 +10,7 @@ type StatsBadgeProps = {
|
|||||||
isInverted?: boolean;
|
isInverted?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const stats = {
|
export const getBadgeType = (stat, rate) => {
|
||||||
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;
|
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -96,8 +44,58 @@ function StatsBadge(props: StatsBadgeProps) {
|
|||||||
tooltipTitle: __('Something to improve.', 'mailpoet'),
|
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;
|
const badge = badges[badgeType] || null;
|
||||||
if (!badge) {
|
if (!badge) {
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user