0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Wrapped easy i18n strings

refs: https://github.com/TryGhost/Ghost/issues/16628

Added wrapping for as many easy / simple i18n strings as possible.
This commit is contained in:
Sam Lord 2023-05-24 14:17:55 +01:00 committed by Sam Lord
parent b99cf16753
commit d3fd8f81e2
7 changed files with 20 additions and 19 deletions

View file

@ -38,6 +38,7 @@ export default class AccountHomePage extends React.Component {
onClose={() => this.context.onAction('closePopup')}
handleSignout={e => this.handleSignout(e)}
supportAddress={supportAddress}
t={this.context.t}
/>
</div>
);

View file

@ -7,7 +7,7 @@ import EmailNewsletterAction from './EmailNewsletterAction';
import EmailPreferencesAction from './EmailPreferencesAction';
const AccountActions = () => {
const {member, onAction, site} = useContext(AppContext);
const {member, onAction, site, t} = useContext(AppContext);
const {name, email} = member;
const openEditProfile = () => {
@ -32,7 +32,7 @@ const AccountActions = () => {
className='gh-portal-btn gh-portal-btn-list'
onClick={e => openEditProfile(e)}
>
Edit
{t('Edit')}
</button>
</section>

View file

@ -1,11 +1,11 @@
const AccountFooter = ({onClose, handleSignout, supportAddress = ''}) => {
const AccountFooter = ({onClose, handleSignout, supportAddress = '', t}) => {
const supportAddressMail = `mailto:${supportAddress}`;
return (
<footer className='gh-portal-account-footer'>
<ul className='gh-portal-account-footermenu'>
<li>
<button data-test-button="footer-signout" className='gh-portal-btn' name='logout' aria-label='logout' onClick={e => handleSignout(e)}>
Sign out
{t('Sign out')}
</button>
</li>
</ul>
@ -14,7 +14,7 @@ const AccountFooter = ({onClose, handleSignout, supportAddress = ''}) => {
<li>
<a data-test-link="footer-support" className='gh-portal-btn gh-portal-btn-branded' href={supportAddressMail} onClick={() => {
supportAddressMail && window.open(supportAddressMail);
}}>Contact support</a>
}}>{t('Contact support')}</a>
</li>
</ul>
</div>

View file

@ -6,7 +6,7 @@ import {useContext} from 'react';
import SubscribeButton from './SubscribeButton';
const AccountWelcome = () => {
const {member, site} = useContext(AppContext);
const {member, site, t} = useContext(AppContext);
const {is_stripe_configured: isStripeConfigured} = site;
if (!isStripeConfigured || hasOnlyFreePlan({site})) {
@ -24,7 +24,7 @@ const AccountWelcome = () => {
const expiryAt = getDateString(expiryDate);
return (
<div className='gh-portal-section'>
<p className='gh-portal-text-center gh-portal-free-ctatext'>Your subscription will expire on {expiryAt}</p>
<p className='gh-portal-text-center gh-portal-free-ctatext'>{t(`Your subscription will expire on {{expiryDate}}`, {expiryDate: expiryAt})}</p>
</div>
);
}
@ -36,20 +36,20 @@ const AccountWelcome = () => {
const trialEnd = getDateString(subscription.trial_end_at);
return (
<div className='gh-portal-section'>
<p className='gh-portal-text-center gh-portal-free-ctatext'>Your subscription will start on {trialEnd}</p>
<p className='gh-portal-text-center gh-portal-free-ctatext'>{t(`Your subscription will start on {{subscriptionStart}}`, {subscriptionStart: trialEnd})}</p>
</div>
);
}
return (
<div className='gh-portal-section'>
<p className='gh-portal-text-center gh-portal-free-ctatext'>Your subscription will renew on {getDateString(currentPeriodEnd)}</p>
<p className='gh-portal-text-center gh-portal-free-ctatext'>{t(`Your subscription will renew on {{renewalDate}}`, {renewalDate: getDateString(currentPeriodEnd)})}</p>
</div>
);
}
return (
<div className='gh-portal-section'>
<p className='gh-portal-text-center gh-portal-free-ctatext'>You currently have a free membership, upgrade to a paid subscription for full access.</p>
<p className='gh-portal-text-center gh-portal-free-ctatext'>{t(`You currently have a free membership, upgrade to a paid subscription for full access.`)}</p>
<SubscribeButton />
</div>
);

View file

@ -5,7 +5,7 @@ import {getDateString} from '../../../../utils/date-time';
import {useContext} from 'react';
const ContinueSubscriptionButton = () => {
const {member, onAction, action, brandColor} = useContext(AppContext);
const {member, onAction, action, brandColor, t} = useContext(AppContext);
const subscription = getMemberSubscription({member});
if (!subscription) {
return null;
@ -15,7 +15,7 @@ const ContinueSubscriptionButton = () => {
if (!subscription.cancel_at_period_end) {
return null;
}
const label = subscription.cancel_at_period_end ? 'Continue subscription' : 'Cancel subscription';
const label = subscription.cancel_at_period_end ? t('Continue subscription') : t('Cancel subscription');
const isRunning = ['cancelSubscription:running'].includes(action);
const disabled = (isRunning) ? true : false;
const isPrimary = !!subscription.cancel_at_period_end;
@ -26,7 +26,7 @@ const ContinueSubscriptionButton = () => {
}
const currentPeriodEnd = subscription.current_period_end;
return (
<p className='gh-portal-text-center gh-portal-free-ctatext'>Your subscription will expire on {getDateString(currentPeriodEnd)}</p>
<p className='gh-portal-text-center gh-portal-free-ctatext'>{t(`Your subscription will expire on {{expiryDate}}`, {expiryDate: getDateString(currentPeriodEnd)})}</p>
);
};

View file

@ -4,11 +4,11 @@ import {getSiteNewsletters, hasMemberGotEmailSuppression} from '../../../../util
import {useContext} from 'react';
function EmailNewsletterAction() {
const {member, site, onAction} = useContext(AppContext);
const {member, site, onAction, t} = useContext(AppContext);
let {newsletters} = member;
const subscribed = !!newsletters?.length;
let label = subscribed ? 'Subscribed' : 'Unsubscribed';
let label = subscribed ? t('Subscribed') : t('Unsubscribed');
const onToggleSubscription = (e, sub) => {
e.preventDefault();
const siteNewsletters = getSiteNewsletters({site});
@ -19,12 +19,12 @@ function EmailNewsletterAction() {
return (
<section>
<div className='gh-portal-list-detail email-newsletter'>
<h3>Email newsletter</h3>
<h3>{t('Email newsletter')}</h3>
<p>{label} {hasMemberGotEmailSuppression({member}) && subscribed && <button
className='gh-portal-btn-text gh-email-faq-page-button'
onClick={() => onAction('switchPage', {page: 'emailReceivingFAQ', lastPage: 'accountHome'})}
>
Not receiving emails?
{t('Not receiving emails?')}
</button>}</p>
</div>
<div>

View file

@ -4,7 +4,7 @@ import {hasOnlyFreePlan} from '../../../../utils/helpers';
import {useContext} from 'react';
const SubscribeButton = () => {
const {site, action, brandColor, onAction} = useContext(AppContext);
const {site, action, brandColor, onAction, t} = useContext(AppContext);
const {is_stripe_configured: isStripeConfigured} = site;
if (!isStripeConfigured || hasOnlyFreePlan({site})) {
@ -22,7 +22,7 @@ const SubscribeButton = () => {
<ActionButton
dataTestId={'view-plans'}
isRunning={isRunning}
label="View plans"
label={t('View plans')}
onClick={() => openPlanPage()}
brandColor={brandColor}
style={{width: '100%'}}