Skip to content

Commit

Permalink
Rename the default translation namespace to core #114
Browse files Browse the repository at this point in the history
  • Loading branch information
knightburton committed Feb 9, 2022
1 parent e7bafb3 commit 656d260
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/layout/AppAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ALERT_AUTOHIDE_DURATION } from 'constants/core';
const Transition = (props: SlideProps): JSX.Element => <Slide {...props} direction="right" />;

const AppAlert = (): JSX.Element => {
const { t } = useTranslation(['common', 'alert', 'translation']);
const { t } = useTranslation(['common', 'alert', 'core']);
const dispatch = useDispatch();
const alert = useSelector<IAlert | undefined>(getMostRecentAlert);
const [open, setOpen] = useState(false);
Expand Down
12 changes: 6 additions & 6 deletions src/components/pages/Account/Information/PersonalForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const schema = (t: (key: string, options?: object) => string, user: User | null)
];

const PersonalForm = () => {
const { t } = useTranslation(['common', 'translation', 'alert']);
const { t } = useTranslation(['common', 'core', 'alert']);
const [open, setOpen] = useState<boolean>(false);
const [formHasChnaged, setFormHasChanged] = useState<boolean>(false);
const [data, setData] = useState<InformationForm>({ displayName: '', email: '' });
Expand Down Expand Up @@ -70,7 +70,7 @@ const PersonalForm = () => {

return (
<Paper>
<Title variant="secondary">{t('translation:account.personal')}</Title>
<Title variant="secondary">{t('core:account.personal')}</Title>
<Form onSubmit={handleSubmit}>
<FormText
id="displayName"
Expand All @@ -93,18 +93,18 @@ const PersonalForm = () => {
<Stack direction="row" justifyContent="flex-end" spacing={2} sx={{ mt: 2 }}>
{formHasChnaged && (
<Button onClick={handleCancelClick} variant="contained" color="warning" disabled={inProgress}>
{t('translation:account.cancelEdit')}
{t('core:account.cancelEdit')}
</Button>
)}
<Button type="submit" variant="contained" disabled={!formHasChnaged} loading={inProgress}>
{t('translation:account.save')}
{t('core:account.save')}
</Button>
</Stack>
</Form>
<Confirmation
id="update-account"
title={t('translation:account.updateInformation')}
description={t('translation:account.updateInformationDescription')}
title={t('core:account.updateInformation')}
description={t('core:account.updateInformationDescription')}
onAgree={handleAgree}
onDisagree={handleDisagree}
open={open}
Expand Down
16 changes: 8 additions & 8 deletions src/components/pages/Account/Information/PhotoForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getInProgressByType, getUserProfilePhoto, updateProfilePhoto, deletePro
import { MAX_FILE_SIZE_IN_B, MAX_FILE_SIZE_IN_MB } from '../../../../../constants/core';

const PhotoForm = (): JSX.Element => {
const { t } = useTranslation(['translation', 'common', 'alert']);
const { t } = useTranslation(['core', 'common', 'alert']);
const [hover, setHover] = useState<boolean>(false);
const [error, setError] = useState<boolean>(false);
const [file, setFile] = useState<File>();
Expand Down Expand Up @@ -64,7 +64,7 @@ const PhotoForm = (): JSX.Element => {

return (
<Paper>
<Title variant="secondary">{t('translation:account.image')}</Title>
<Title variant="secondary">{t('core:account.image')}</Title>
<Stack direction="column" justifyContent="center" alignItems="center" spacing={2}>
<Box
sx={({ spacing }) => ({
Expand Down Expand Up @@ -103,7 +103,7 @@ const PhotoForm = (): JSX.Element => {
<>
<NoPhotographyOutlinedIcon color="disabled" />
<Typography variant="caption" color="text.secondary">
{t('translation:account.imageMissing')}
{t('core:account.imageMissing')}
</Typography>
</>
)}
Expand All @@ -127,7 +127,7 @@ const PhotoForm = (): JSX.Element => {
})}
>
<AddAPhotoIcon />
<Typography variant="caption">{t('translation:account.imageAdd')}</Typography>
<Typography variant="caption">{t('core:account.imageAdd')}</Typography>
</Box>
)}
</Box>
Expand All @@ -137,10 +137,10 @@ const PhotoForm = (): JSX.Element => {
</Typography>
)}
<Typography variant="caption" color="text.secondary">
{t('translation:account.imageTypes')}
{t('core:account.imageTypes')}
</Typography>
<Typography variant="caption" color="text.secondary">
{t('translation:account.imageSize', { limit: MAX_FILE_SIZE_IN_MB })}
{t('core:account.imageSize', { limit: MAX_FILE_SIZE_IN_MB })}
</Typography>
<Input value="" inputProps={{ ref: fileInput, accept: '.jpeg,.jpg,.png,.gif' }} type="file" sx={{ display: 'none' }} onChange={handleInputChange} />
</Stack>
Expand All @@ -152,8 +152,8 @@ const PhotoForm = (): JSX.Element => {
) : (
<Confirmation
id="delete-profile-photo"
title={t('translation:account.imageDelete')}
description={t('translation:account.imageDeleteDescription')}
title={t('core:account.imageDelete')}
description={t('core:account.imageDeleteDescription')}
onAgree={handleDeleteAgree}
toggle={confirmationToggle}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const schema = (t: (key: string, options?: object) => string): Schema<ChangePass
];

const ChangePasswordForm = (): JSX.Element => {
const { t } = useTranslation(['common', 'translation', 'alert']);
const { t } = useTranslation(['common', 'core', 'alert']);
const dispatch = useDispatch();

const { fields, handleSubmit, handleChange } = useForm<ChangePasswordFormInterface>({
Expand All @@ -46,27 +46,27 @@ const ChangePasswordForm = (): JSX.Element => {

return (
<Paper>
<Title variant="secondary">{t('translation:account.changePassword')}</Title>
<Title variant="secondary">{t('core:account.changePassword')}</Title>
<Form onSubmit={handleSubmit}>
<FormText
id="newPassword"
type="password"
label={t('translation:account.newPassword')}
label={t('core:account.newPassword')}
onChange={handleChange}
value={fields.newPassword.value}
error={fields.newPassword.error}
/>
<FormText
id="confirmPassword"
type="password"
label={t('translation:account.confirmPassword')}
label={t('core:account.confirmPassword')}
onChange={handleChange}
value={fields.confirmPassword.value}
error={fields.confirmPassword.error}
/>
<ButtonContainer align="flex-end">
<Button onClick={() => handleSubmit()} variant="contained">
{t('translation:account.changePassword')}
{t('core:account.changePassword')}
</Button>
</ButtonContainer>
</Form>
Expand Down
8 changes: 4 additions & 4 deletions src/components/pages/SignIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EMAIL, TEXT_MIN, TEXT_MAX } from 'constants/validation';
type OnSubmitCallback = (credentials: SignInCredentials) => void;

const SignIn = (): JSX.Element => {
const { t } = useTranslation(['common', 'alert', 'translation']);
const { t } = useTranslation(['common', 'alert', 'core']);
const dispatch = useDispatch();
const isLoading = useSelector<boolean>(getIsLoading);
const onSubmit = useCallback<OnSubmitCallback>(credentials => dispatch(signIn(credentials)), [dispatch]);
Expand All @@ -37,7 +37,7 @@ const SignIn = (): JSX.Element => {

return (
<Container maxWidth="xs">
<Title>{t('translation:signIn.title')}</Title>
<Title>{t('core:signIn.title')}</Title>
<Form onSubmit={handleSubmit}>
<FormText
id="email"
Expand All @@ -60,10 +60,10 @@ const SignIn = (): JSX.Element => {
/>
<ButtonContainer align="flex-end">
<Button type="submit" variant="contained" loading={isLoading}>
{t('translation:signIn.title')}
{t('core:signIn.title')}
</Button>
<Button color="secondary" disabled={isLoading}>
{t('translation:forgotPassword.title')}
{t('core:forgotPassword.title')}
</Button>
</ButtonContainer>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"personal": "Personal Informations",
"emailVerification": "Email Verification",
"emailVerified": "Your email address is $t(translation:account.verified_{{verified}})",
"emailVerified": "Your email address is $t(core:account.verified_{{verified}})",
"verified_true": "verified",
"verified_false": "not verified",
"newPassword": "New Password",
Expand Down
8 changes: 4 additions & 4 deletions src/localization/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { initReactI18next } from 'react-i18next';

import enAlert from './en/alert.json';
import enCommon from './en/common.json';
import enTranslation from './en/translation.json';
import enCore from './en/core.json';

const debug = process.env.NODE_ENV === 'development';

i18n.use(initReactI18next).init({
defaultNS: 'translation',
defaultNS: 'core',
resources: {
en: {
common: enCommon,
alert: enAlert,
translation: enTranslation,
core: enCore,
},
},
ns: ['alert', 'common', 'translation'],
ns: ['alert', 'common', 'core'],
fallbackLng: 'en',
lng: 'en',
interpolation: {
Expand Down
6 changes: 3 additions & 3 deletions src/localization/react-i18next.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'react-i18next';
import alert from './en/alert.json';
import common from './en/common.json';
import translation from './en/translation.json';
import core from './en/core.json';

declare module 'react-i18next' {
interface CustomTypeOptions {
defaultNS: 'translation';
defaultNS: 'core';
resources: {
alert: typeof alert;
common: typeof common;
translation: typeof translation;
core: typeof core;
};
}
}

0 comments on commit 656d260

Please sign in to comment.