Make more strings localizable

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
ads-account
marcin mikołajczak 2022-11-26 16:00:54 +01:00
rodzic 8b4390681b
commit 34aee08a09
8 zmienionych plików z 26 dodań i 14 usunięć

Wyświetl plik

@ -67,6 +67,7 @@ const messages = defineMessages({
userEndorsed: { id: 'account.endorse.success', defaultMessage: 'You are now featuring @{acct} on your profile' }, userEndorsed: { id: 'account.endorse.success', defaultMessage: 'You are now featuring @{acct} on your profile' },
userUnendorsed: { id: 'account.unendorse.success', defaultMessage: 'You are no longer featuring @{acct}' }, userUnendorsed: { id: 'account.unendorse.success', defaultMessage: 'You are no longer featuring @{acct}' },
profileExternal: { id: 'account.profile_external', defaultMessage: 'View profile on {domain}' }, profileExternal: { id: 'account.profile_external', defaultMessage: 'View profile on {domain}' },
header: { id: 'account.header.alt', defaultMessage: 'Profile header' },
}); });
interface IHeader { interface IHeader {
@ -556,7 +557,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
<a href={account.header} onClick={handleHeaderClick} target='_blank'> <a href={account.header} onClick={handleHeaderClick} target='_blank'>
<StillImage <StillImage
src={account.header} src={account.header}
alt='Profile Header' alt={intl.formatMessage(messages.header)}
/> />
</a> </a>
)} )}

Wyświetl plik

@ -1,6 +1,6 @@
import classNames from 'clsx'; import classNames from 'clsx';
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { defineMessages, FormattedMessage } from 'react-intl';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { patchMe } from 'soapbox/actions/me'; import { patchMe } from 'soapbox/actions/me';
@ -11,6 +11,10 @@ import resizeImage from 'soapbox/utils/resize-image';
import type { AxiosError } from 'axios'; import type { AxiosError } from 'axios';
const messages = defineMessages({
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
});
/** Default avatar filenames from various backends */ /** Default avatar filenames from various backends */
const DEFAULT_AVATARS = [ const DEFAULT_AVATARS = [
'/avatars/original/missing.png', // Mastodon '/avatars/original/missing.png', // Mastodon
@ -64,7 +68,7 @@ const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
if (error.response?.status === 422) { if (error.response?.status === 422) {
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', ''))); dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
} else { } else {
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.')); dispatch(snackbar.error(messages.error));
} }
}); });
}).catch(console.error); }).catch(console.error);

Wyświetl plik

@ -11,6 +11,7 @@ import type { AxiosError } from 'axios';
const messages = defineMessages({ const messages = defineMessages({
bioPlaceholder: { id: 'onboarding.bio.placeholder', defaultMessage: 'Tell the world a little about yourself…' }, bioPlaceholder: { id: 'onboarding.bio.placeholder', defaultMessage: 'Tell the world a little about yourself…' },
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
}); });
const BioStep = ({ onNext }: { onNext: () => void }) => { const BioStep = ({ onNext }: { onNext: () => void }) => {
@ -37,7 +38,7 @@ const BioStep = ({ onNext }: { onNext: () => void }) => {
if (error.response?.status === 422) { if (error.response?.status === 422) {
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]); setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
} else { } else {
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.')); dispatch(snackbar.error(messages.error));
} }
}); });
}; };

Wyświetl plik

@ -1,6 +1,6 @@
import classNames from 'clsx'; import classNames from 'clsx';
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { patchMe } from 'soapbox/actions/me'; import { patchMe } from 'soapbox/actions/me';
@ -12,6 +12,11 @@ import resizeImage from 'soapbox/utils/resize-image';
import type { AxiosError } from 'axios'; import type { AxiosError } from 'axios';
const messages = defineMessages({
header: { id: 'account.header.alt', defaultMessage: 'Profile header' },
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
});
/** Default header filenames from various backends */ /** Default header filenames from various backends */
const DEFAULT_HEADERS = [ const DEFAULT_HEADERS = [
'/headers/original/missing.png', // Mastodon '/headers/original/missing.png', // Mastodon
@ -24,6 +29,7 @@ const isDefaultHeader = (url: string) => {
}; };
const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => { const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
const intl = useIntl();
const dispatch = useDispatch(); const dispatch = useDispatch();
const account = useOwnAccount(); const account = useOwnAccount();
@ -65,7 +71,7 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
if (error.response?.status === 422) { if (error.response?.status === 422) {
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', ''))); dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
} else { } else {
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.')); dispatch(snackbar.error(messages.error));
} }
}); });
}).catch(console.error); }).catch(console.error);
@ -90,7 +96,6 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'> <div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'>
<Stack space={10}> <Stack space={10}>
<div className='border border-solid border-gray-200 dark:border-gray-800 rounded-lg'> <div className='border border-solid border-gray-200 dark:border-gray-800 rounded-lg'>
{/* eslint-disable-next-line jsx-a11y/interactive-supports-focus */}
<div <div
role='button' role='button'
className='relative h-24 bg-gray-200 dark:bg-gray-800 rounded-t-md flex items-center justify-center' className='relative h-24 bg-gray-200 dark:bg-gray-800 rounded-t-md flex items-center justify-center'
@ -98,7 +103,7 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
{selectedFile || account?.header && ( {selectedFile || account?.header && (
<StillImage <StillImage
src={selectedFile || account.header} src={selectedFile || account.header}
alt='Profile Header' alt={intl.formatMessage(messages.header)}
className='absolute inset-0 object-cover rounded-t-md' className='absolute inset-0 object-cover rounded-t-md'
/> />
)} )}

Wyświetl plik

@ -11,6 +11,7 @@ import type { AxiosError } from 'axios';
const messages = defineMessages({ const messages = defineMessages({
usernamePlaceholder: { id: 'onboarding.display_name.placeholder', defaultMessage: 'Eg. John Smith' }, usernamePlaceholder: { id: 'onboarding.display_name.placeholder', defaultMessage: 'Eg. John Smith' },
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
}); });
const DisplayNameStep = ({ onNext }: { onNext: () => void }) => { const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
@ -48,7 +49,7 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
if (error.response?.status === 422) { if (error.response?.status === 422) {
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]); setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
} else { } else {
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.')); dispatch(snackbar.error(messages.error));
} }
}); });
}; };

Wyświetl plik

@ -18,7 +18,7 @@ import type { AxiosError } from 'axios';
const messages = defineMessages({ const messages = defineMessages({
success: { id: 'registrations.success', defaultMessage: 'Welcome to {siteTitle}!' }, success: { id: 'registrations.success', defaultMessage: 'Welcome to {siteTitle}!' },
usernameLabel: { id: 'registrations.username.label', defaultMessage: 'Your username' }, usernameLabel: { id: 'registrations.username.label', defaultMessage: 'Your username' },
usernameHint: { id: 'registrations.username.hint', defaultMessage: 'May only contain A-Z, 0-9, and underscores', }, 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.' }, usernameTaken: { id: 'registrations.unprocessable_entity', defaultMessage: 'This username has already been taken.' },
passwordLabel: { id: 'registrations.password.label', defaultMessage: 'Password' }, passwordLabel: { id: 'registrations.password.label', defaultMessage: 'Password' },
error: { id: 'registrations.error', defaultMessage: 'Failed to register your account.' }, error: { id: 'registrations.error', defaultMessage: 'Failed to register your account.' },

Wyświetl plik

@ -23,7 +23,7 @@ describe('<EmailVerification />', () => {
it('successfully submits', async() => { it('successfully submits', async() => {
render(<EmailVerification />); render(<EmailVerification />);
await userEvent.type(screen.getByLabelText('Email Address'), 'foo@bar.com{enter}'); await userEvent.type(screen.getByLabelText('E-mail address'), 'foo@bar.com{enter}');
await waitFor(() => { await waitFor(() => {
fireEvent.submit( fireEvent.submit(
@ -50,7 +50,7 @@ describe('<EmailVerification />', () => {
it('renders errors', async() => { it('renders errors', async() => {
render(<EmailVerification />); render(<EmailVerification />);
await userEvent.type(screen.getByLabelText('Email Address'), 'foo@bar.com{enter}'); await userEvent.type(screen.getByLabelText('E-mail address'), 'foo@bar.com{enter}');
await waitFor(() => { await waitFor(() => {
fireEvent.submit( fireEvent.submit(

Wyświetl plik

@ -432,7 +432,7 @@
"emoji_button.objects": "Objects", "emoji_button.objects": "Objects",
"emoji_button.people": "People", "emoji_button.people": "People",
"emoji_button.recent": "Frequently used", "emoji_button.recent": "Frequently used",
"emoji_button.search": "Search...", "emoji_button.search": "Search",
"emoji_button.search_results": "Search results", "emoji_button.search_results": "Search results",
"emoji_button.symbols": "Symbols", "emoji_button.symbols": "Symbols",
"emoji_button.travel": "Travel & Places", "emoji_button.travel": "Travel & Places",
@ -1071,7 +1071,7 @@
"upload_form.description": "Describe for the visually impaired", "upload_form.description": "Describe for the visually impaired",
"upload_form.preview": "Preview", "upload_form.preview": "Preview",
"upload_form.undo": "Delete", "upload_form.undo": "Delete",
"upload_progress.label": "Uploading...", "upload_progress.label": "Uploading",
"video.close": "Close video", "video.close": "Close video",
"video.download": "Download file", "video.download": "Download file",
"video.exit_fullscreen": "Exit full screen", "video.exit_fullscreen": "Exit full screen",