Make some strings localizable

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
environments/review-intl-ck8zku/deployments/1543
marcin mikołajczak 2 years ago
parent 275a4c581b
commit 8b4390681b

@ -38,6 +38,7 @@ const messages = defineMessages({
developers: { id: 'navigation.developers', defaultMessage: 'Developers' },
addAccount: { id: 'profile_dropdown.add_account', defaultMessage: 'Add an existing account' },
followRequests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
close: { id: 'lightbox.close', defaultMessage: 'Close' },
});
interface ISidebarLink {
@ -148,7 +149,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
onClick={handleClose}
>
<IconButton
title='close'
title={intl.formatMessage(messages.close)}
onClick={handleClose}
src={require('@tabler/icons/x.svg')}
ref={closeButtonRef}

@ -11,6 +11,7 @@ const token = new URLSearchParams(window.location.search).get('reset_password_to
const messages = defineMessages({
resetPasswordFail: { id: 'reset_password.fail', defaultMessage: 'Expired token, please try again.' },
passwordPlaceholder: { id: 'reset_password.password.placeholder', defaultMessage: 'Placeholder' },
});
const Statuses = {
@ -66,11 +67,11 @@ const PasswordResetConfirm = () => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'>
<Form onSubmit={handleSubmit}>
<FormGroup labelText='Password' errors={renderErrors()}>
<FormGroup labelText={<FormattedMessage id='reset_password.password.label' defaultMessage='Password' />} errors={renderErrors()}>
<Input
type='password'
name='password'
placeholder='Password'
placeholder={intl.formatMessage(messages.passwordPlaceholder)}
onChange={onChange}
required
/>

@ -1,4 +1,5 @@
import React, { useEffect, useRef } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import {
@ -18,6 +19,10 @@ import ChatBox from './chat-box';
import type { Account as AccountEntity } from 'soapbox/types/entities';
const messages = defineMessages({
close: { id: 'chat_window.close', defaultMessage: 'Close chat' },
});
type WindowState = 'open' | 'minimized';
const getChat = makeGetChat();
@ -33,6 +38,7 @@ interface IChatWindow {
/** Floating desktop chat window. */
const ChatWindow: React.FC<IChatWindow> = ({ idx, chatId, windowState }) => {
const intl = useIntl();
const dispatch = useAppDispatch();
const displayFqn = useAppSelector(getDisplayFqn);
@ -98,7 +104,7 @@ const ChatWindow: React.FC<IChatWindow> = ({ idx, chatId, windowState }) => {
@{getAcct(account, displayFqn)}
</button>
<div className='pane__close'>
<IconButton src={require('@tabler/icons/x.svg')} title='Close chat' onClick={handleChatClose(chat.id)} />
<IconButton src={require('@tabler/icons/x.svg')} title={intl.formatMessage(messages.close)} onClick={handleChatClose(chat.id)} />
</div>
</HStack>
<div className='pane__content'>

@ -29,6 +29,7 @@ const isJSONValid = (text: any): boolean => {
const messages = defineMessages({
heading: { id: 'column.settings_store', defaultMessage: 'Settings store' },
advanced: { id: 'developers.settings_store.advanced', defaultMessage: 'Advanced settings' },
hint: { id: 'developers.settings_store.hint', defaultMessage: 'It is possible to directly edit your user settings here. BE CAREFUL! Editing this section can break your account, and you will only be able to recover through the API.' },
});
@ -98,7 +99,7 @@ const SettingsStore: React.FC = () => {
</Form>
<CardHeader>
<CardTitle title='Advanced settings' />
<CardTitle title={intl.formatMessage(messages.advanced)} />
</CardHeader>
<List>

@ -1,5 +1,5 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { patchMe } from 'soapbox/actions/me';
@ -9,7 +9,12 @@ import { useOwnAccount } from 'soapbox/hooks';
import type { AxiosError } from 'axios';
const messages = defineMessages({
bioPlaceholder: { id: 'onboarding.bio.placeholder', defaultMessage: 'Tell the world a little about yourself…' },
});
const BioStep = ({ onNext }: { onNext: () => void }) => {
const intl = useIntl();
const dispatch = useDispatch();
const account = useOwnAccount();
@ -56,13 +61,13 @@ const BioStep = ({ onNext }: { onNext: () => void }) => {
<Stack space={5}>
<div className='sm:pt-10 sm:w-2/3 mx-auto'>
<FormGroup
hintText='Max 500 characters'
labelText='Bio'
hintText={<FormattedMessage id='onboarding.bio.hint' defaultMessage='Max 500 characters' />}
labelText={<FormattedMessage id='edit_profile.fields.bio_label' defaultMessage='Bio' />}
errors={errors}
>
<Textarea
onChange={(event) => setValue(event.target.value)}
placeholder='Tell the world a little about yourself…'
placeholder={intl.formatMessage(messages.bioPlaceholder)}
value={value}
maxLength={500}
/>

@ -138,7 +138,11 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
<Stack justifyContent='center' space={2}>
<Button block theme='primary' type='button' onClick={onNext} disabled={isDefault && isDisabled || isSubmitting}>
{isSubmitting ? 'Saving…' : 'Next'}
{isSubmitting ? (
<FormattedMessage id='onboarding.saving' defaultMessage='Saving…' />
) : (
<FormattedMessage id='onboarding.next' defaultMessage='Next' />
)}
</Button>
{isDisabled && (

@ -1,5 +1,5 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { patchMe } from 'soapbox/actions/me';
@ -9,7 +9,12 @@ import { useOwnAccount } from 'soapbox/hooks';
import type { AxiosError } from 'axios';
const messages = defineMessages({
usernamePlaceholder: { id: 'onboarding.display_name.placeholder', defaultMessage: 'Eg. John Smith' },
});
const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
const intl = useIntl();
const dispatch = useDispatch();
const account = useOwnAccount();
@ -68,12 +73,12 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
<Stack space={5}>
<FormGroup
hintText={hintText}
labelText='Display name'
labelText={<FormattedMessage id='onboarding.display_name.label' defaultMessage='Display name' />}
errors={errors}
>
<Input
onChange={(event) => setValue(event.target.value)}
placeholder='Eg. John Smith'
placeholder={intl.formatMessage(messages.usernamePlaceholder)}
type='text'
value={value}
maxLength={30}
@ -88,7 +93,11 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
disabled={isDisabled || isSubmitting}
onClick={handleSubmit}
>
{isSubmitting ? 'Saving…' : 'Next'}
{isSubmitting ? (
<FormattedMessage id='onboarding.saving' defaultMessage='Saving…' />
) : (
<FormattedMessage id='onboarding.next' defaultMessage='Next' />
)}
</Button>
<Button block theme='tertiary' type='button' onClick={onNext}>

@ -15,6 +15,7 @@ import Sonar from './sonar';
import type { AxiosError } from 'axios';
const messages = defineMessages({
menu: { id: 'header.menu.title', defaultMessage: 'Open menu' },
home: { id: 'header.home.label', defaultMessage: 'Home' },
login: { id: 'header.login.label', defaultMessage: 'Log in' },
register: { id: 'header.register.label', defaultMessage: 'Register' },
@ -79,7 +80,7 @@ const Header = () => {
</div>
<IconButton
title='Open Menu'
title={intl.formatMessage(messages.menu)}
src={require('@tabler/icons/menu-2.svg')}
onClick={open}
className='md:hidden mr-4 bg-transparent text-gray-700 dark:text-gray-600 hover:text-gray-600'

@ -30,7 +30,7 @@ const BoostModal: React.FC<IBoostModal> = ({ status, onReblog, onClose }) => {
return (
<Modal
title='Repost?'
title={<FormattedMessage id='boost_modal.title' defaultMessage='Repost?' />}
confirmationAction={handleReblog}
confirmationText={intl.formatMessage(buttonText)}
>

@ -150,7 +150,7 @@ const VerifySmsModal: React.FC<IVerifySmsModal> = ({ onClose }) => {
);
case Statuses.READY:
return (
<FormGroup labelText='Phone Number'>
<FormGroup labelText={<FormattedMessage id='sms_verification.phone.label' defaultMessage='Phone Number' />}>
<PhoneInput
value={phone}
onChange={onChange}

@ -16,22 +16,12 @@ import PasswordIndicator from './components/password-indicator';
import type { AxiosError } from 'axios';
const messages = defineMessages({
success: {
id: 'registrations.success',
defaultMessage: 'Welcome to {siteTitle}!',
},
usernameHint: {
id: 'registrations.username.hint',
defaultMessage: 'May only contain A-Z, 0-9, and underscores',
},
usernameTaken: {
id: 'registrations.unprocessable_entity',
defaultMessage: 'This username has already been taken.',
},
error: {
id: 'registrations.error',
defaultMessage: 'Failed to register your account.',
},
success: { id: 'registrations.success', defaultMessage: 'Welcome to {siteTitle}!' },
usernameLabel: { id: 'registrations.username.label', defaultMessage: 'Your username' },
usernameHint: { id: 'registrations.username.hint', defaultMessage: 'May only contain A-Z, 0-9, and underscores', },
usernameTaken: { id: 'registrations.unprocessable_entity', defaultMessage: 'This username has already been taken.' },
passwordLabel: { id: 'registrations.password.label', defaultMessage: 'Password' },
error: { id: 'registrations.error', defaultMessage: 'Failed to register your account.' },
});
const initialState = {
@ -108,7 +98,7 @@ const Registration = () => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto space-y-4'>
<Form onSubmit={handleSubmit}>
<FormGroup labelText='Your username' hintText={intl.formatMessage(messages.usernameHint)}>
<FormGroup labelText={intl.formatMessage(messages.usernameLabel)} hintText={intl.formatMessage(messages.usernameHint)}>
<Input
name='username'
type='text'
@ -120,7 +110,7 @@ const Registration = () => {
/>
</FormGroup>
<FormGroup labelText='Password'>
<FormGroup labelText={intl.formatMessage(messages.passwordLabel)}>
<Input
name='password'
type='password'
@ -140,7 +130,7 @@ const Registration = () => {
type='submit'
disabled={isLoading || !hasValidPassword}
>
Register
<FormattedMessage id='header.register.label' defaultMessage='Register' />
</Button>
{(links.get('termsOfService') && links.get('privacyPolicy')) ? (

@ -61,13 +61,21 @@ const AgeVerification = () => {
<Datepicker onChange={onChange} />
<Text theme='muted' size='sm'>
{siteTitle} requires users to be at least {ageMinimum} years old to
access its platform. Anyone under the age of {ageMinimum} years old
cannot access this platform.
<FormattedMessage
id='age_verification.body'
defaultMessage='{siteTitle} requires users to be at least {ageMinimum} years old to access its platform. Anyone under the age of {ageMinimum} years old cannot access this platform.'
values={{
siteTitle,
ageMinimum,
}}
/>
</Text>
<div className='text-center'>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>Next</Button>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>
<FormattedMessage id='onboarding.next' defaultMessage='Next' />
</Button>
</div>
</Form>
</div>

@ -13,6 +13,7 @@ const messages = defineMessages({
verificationFail: { id: 'email_verification.fail', defaultMessage: 'Failed to request email verification.' },
verificationFailTakenAlert: { id: 'email_verifilcation.exists', defaultMessage: 'This email has already been taken.' },
verificationFailTaken: { id: 'email_verification.taken', defaultMessage: 'is taken' },
emailLabel: { id: 'email_verification.email.label', defaultMessage: 'E-mail address' },
});
const Statuses = {
@ -122,7 +123,7 @@ const EmailVerification = () => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'>
<Form onSubmit={handleSubmit}>
<FormGroup labelText='Email Address' errors={errors}>
<FormGroup labelText={intl.formatMessage(messages.emailLabel)} errors={errors}>
<Input
type='email'
value={email}
@ -134,7 +135,9 @@ const EmailVerification = () => {
</FormGroup>
<div className='text-center'>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>Next</Button>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>
<FormattedMessage id='onboarding.next' defaultMessage='Next' />
</Button>
</div>
</Form>
</div>

@ -13,6 +13,7 @@ const messages = defineMessages({
verificationSuccess: { id: 'sms_verification.success', defaultMessage: 'A verification code has been sent to your phone number.' },
verificationFail: { id: 'sms_verification.fail', defaultMessage: 'Failed to send SMS message to your phone number.' },
verificationExpired: { id: 'sms_verification.expired', defaultMessage: 'Your SMS token has expired.' },
phoneLabel: { id: 'sms_verification.phone.label', defaultMessage: 'Phone number' },
});
const Statuses = {
@ -98,7 +99,7 @@ const SmsVerification = () => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto space-y-4'>
<Text theme='muted' size='sm' align='center'>
We sent you a 6-digit code via SMS. Enter it below.
<FormattedMessage id='sms_verification.sent.body' defaultMessage='We sent you a 6-digit code via SMS. Enter it below.' />
</Text>
<OtpInput
@ -120,7 +121,7 @@ const SmsVerification = () => {
onClick={resendVerificationCode}
disabled={requestedAnother}
>
Resend verification code?
<FormattedMessage id='sms_verification.sent.actions.resend' defaultMessage='Resend verification code?' />
</Button>
</div>
</div>
@ -138,7 +139,7 @@ const SmsVerification = () => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'>
<Form onSubmit={handleSubmit}>
<FormGroup labelText='Phone Number'>
<FormGroup labelText={intl.formatMessage(messages.phoneLabel)}>
<PhoneInput
value={phone}
onChange={onChange}
@ -147,7 +148,9 @@ const SmsVerification = () => {
</FormGroup>
<div className='text-center'>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>Next</Button>
<Button block theme='primary' type='submit' disabled={isLoading || !isValid}>
<FormattedMessage id='onboarding.next' defaultMessage='Next' />
</Button>
</div>
</Form>
</div>

@ -1,4 +1,5 @@
import React, { useEffect } from 'react';
import { FormattedMessage } from 'react-intl';
import { useDispatch } from 'react-redux';
import { Link } from 'react-router-dom';
@ -42,7 +43,7 @@ const WaitlistPage = (/* { account } */) => {
<div className='absolute inset-y-0 right-0 flex items-center pr-2'>
<Button onClick={onClickLogOut} theme='primary' to='/logout'>
Sign out
<FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' />
</Button>
</div>
</div>
@ -55,13 +56,17 @@ const WaitlistPage = (/* { account } */) => {
<Stack space={2}>
<Text size='lg' theme='muted' align='center' weight='medium'>
Welcome back to {title}! You were previously placed on our
waitlist. Please verify your phone number to receive
immediate access to your account!
<FormattedMessage
id='waitlist.body'
defaultMessage='Welcome back to {title}! You were previously placed on our waitlist. Please verify your phone number to receive immediate access to your account!'
values={{ title }}
/>
</Text>
<div className='text-center'>
<Button onClick={openVerifySmsModal} theme='primary'>Verify phone number</Button>
<Button onClick={openVerifySmsModal} theme='primary'>
<FormattedMessage id='waitlist.actions.verify_number' defaultMessage='Verify phone number' />
</Button>
</div>
</Stack>
</Stack>

Loading…
Cancel
Save