From 91ce2fd21f3ca8a58324817774a584484a7a9142 Mon Sep 17 00:00:00 2001 From: Sam Lord Date: Wed, 24 May 2023 14:22:47 +0100 Subject: [PATCH] Wrapped i18n strings for paid account actions refs: https://github.com/TryGhost/Ghost/issues/16628 Separate commit for these, this change was a little more complex since the string "Complimentary" was repeated several times, with different additional context. I decided to keep "Complimentary" by itself as a translatable string, and concatenated a second string for the expiry. If this would be better as 3 strings, then we could switch to having these: - "Complimentary" - "Complimentary ({{label}})" - "Complimentary - Expires {{expiry date}}" ^ Makes sense only if the use of parentheses & hyphens would be changed in other locales --- .../components/PaidAccountActions.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ghost/portal/src/components/pages/AccountHomePage/components/PaidAccountActions.js b/ghost/portal/src/components/pages/AccountHomePage/components/PaidAccountActions.js index 2809ae6e5f..9a62234e10 100644 --- a/ghost/portal/src/components/pages/AccountHomePage/components/PaidAccountActions.js +++ b/ghost/portal/src/components/pages/AccountHomePage/components/PaidAccountActions.js @@ -6,7 +6,7 @@ import {ReactComponent as OfferTagIcon} from '../../../../images/icons/offer-tag import {useContext} from 'react'; const PaidAccountActions = () => { - const {member, site, onAction} = useContext(AppContext); + const {member, site, onAction, t} = useContext(AppContext); const onEditBilling = () => { const subscription = getMemberSubscription({member}); @@ -33,13 +33,13 @@ const PaidAccountActions = () => { const {amount = 0, currency, interval} = price; label = `${Intl.NumberFormat('en', {currency, style: 'currency'}).format(amount / 100)}/${interval}`; } - let offerLabelStr = getOfferLabel({price, offer, subscriptionStartDate: startDate}); + let offerLabelStr = getOfferLabel({price, offer, subscriptionStartDate: startDate, t}); const compExpiry = getCompExpiry({member}); if (isComplimentary) { if (compExpiry) { - label = `Complimentary - Expires ${compExpiry}`; + label = `${t('Complimentary')} - ${t('Expires {{expiryDate}}', {expiryDate: compExpiry})}`; } else { - label = label ? `Complimentary (${label})` : `Complimentary`; + label = label ? `${t('Complimentary')} (${label})` : t(`Complimentary`); } } let oldPriceClassName = ''; @@ -68,7 +68,7 @@ const PaidAccountActions = () => {

{label}

- + ); } @@ -93,7 +93,7 @@ const PaidAccountActions = () => { className='gh-portal-btn gh-portal-btn-list' onClick={e => openUpdatePlan(e)} data-test-button='change-plan' > - Change + {t('Change')} ); }; @@ -114,7 +114,7 @@ const PaidAccountActions = () => { const {action} = useContext(AppContext); const label = action === 'editBilling:running' ? ( - ) : 'Update'; + ) : t('Update'); if (isComplimentary) { return null; } @@ -122,7 +122,7 @@ const PaidAccountActions = () => { return (
-

Billing info

+

{t('Billing info')}