Skip to content

Commit

Permalink
fix(i18n): t function on withTitle hoc #871
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoirelacoste committed Mar 25, 2021
1 parent c3d6b3f commit 5aa2b9f
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/app/content/App/Account/About/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ export const About = ({ installationDate, extensionVersion }: AboutProps) => {
);
};

export default compose(withConnect, withTitle<AboutProps>('À propos'))(About);
export default compose(
withConnect,
withTitle<AboutProps>('title.about')
)(About);
2 changes: 1 addition & 1 deletion src/app/content/App/Account/Filters/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const Filters = () => {
return <ContentTitleTop>{t('common.filters')}</ContentTitleTop>;
};

export default withTitle<{}>('Mes Filtres')(Filters);
export default withTitle<{}>('title.filters')(Filters);
2 changes: 1 addition & 1 deletion src/app/content/App/Account/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const Menu = ({ match }: MenuProps) => {
);
};

export default withTitle<MenuProps>('Options')(Menu);
export default withTitle<MenuProps>('title.options')(Menu);
2 changes: 1 addition & 1 deletion src/app/content/App/Contribute/ContributeScreen/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withTitle from 'app/hocs/withTitle';
import ContributeScreen from './ContributeScreen';

export default withTitle('poster une information ici')(ContributeScreen);
export default withTitle('title.post_form')(ContributeScreen);
2 changes: 1 addition & 1 deletion src/app/content/App/Contribute/PreviewScreen/withTitle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withTitle from '../../../../hocs/withTitle';
import { PreviewScreenOwnProps } from './PreviewScreen';

export default withTitle<PreviewScreenOwnProps>('Prévisualisation');
export default withTitle<PreviewScreenOwnProps>('title.preview');
2 changes: 1 addition & 1 deletion src/app/content/App/Help/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ export const Help = () => {
);
};

export default withTitle<{}>('Aide')(Help);
export default withTitle<{}>('title.help')(Help);
2 changes: 1 addition & 1 deletion src/app/content/App/Notice/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ export const Details = ({

export default compose(
withConnect,
withTitle<DetailsScreenProps>('Détail de la contribution')
withTitle<DetailsScreenProps>('title.contribution_details')
)(Details);
2 changes: 1 addition & 1 deletion src/app/content/App/Question/FormScreen/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withTitle from 'app/hocs/withTitle';
import FormScreen from './FormScreen';

export default withTitle('Demander une information ici')(FormScreen);
export default withTitle('title.ask_info_form')(FormScreen);
2 changes: 1 addition & 1 deletion src/app/content/App/Question/PreviewScreen/withTitle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withTitle from '../../../../hocs/withTitle';
import { PreviewScreenOwnProps } from './PreviewScreen';

export default withTitle<PreviewScreenOwnProps>('Prévisualisation');
export default withTitle<PreviewScreenOwnProps>('title.preview');
2 changes: 1 addition & 1 deletion src/app/content/App/Subscriptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import Subscriptions, { SubscriptionsScreenProps } from './Subscriptions';

export default compose(
withConnect,
withTitle<SubscriptionsScreenProps>('Abonnements')
withTitle<SubscriptionsScreenProps>('title.subscriptions')
)(Subscriptions);
2 changes: 2 additions & 0 deletions src/app/hocs/withTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ComponentType, useLayoutEffect } from 'react';
import { connect } from 'react-redux';
import { removeUITitle, setUITitle } from '../content/actions/ui/title';
import i18next from 'i18next';

interface TitleProps {
setUITitle: (title: string) => void;
Expand All @@ -19,6 +20,7 @@ const mapDispatchToProps: TitleProps = {
const withTitle = <TComponentProps extends {}>(title: string | undefined) => (
Component: ComponentType<TComponentProps & TitleManipulationProps>
) => {
if (title) title = i18next.t(title);
const ComponentWithTitleEffect = ({
setUITitle,
removeUITitle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import styled from 'styled-components';
import { Link } from 'components/atoms';
import { useTranslation } from 'react-i18next';

const LinkNoNotice = styled(Link)`
display: inline-block;
Expand All @@ -21,4 +22,7 @@ const LinkNoNotice = styled(Link)`
}
`;

export default () => <LinkNoNotice to="/contribute">Poster</LinkNoNotice>;
export default () => {
const { t } = useTranslation();
return <LinkNoNotice to="/contribute">{t('action.post')}</LinkNoNotice>;
};
14 changes: 13 additions & 1 deletion src/i18n/resources/en/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,16 @@
"thanks": "Thanks for your request.",
"message": "It will be transmitted right away to the relevant guide(s). You'll receive their response via email."
}
}}
},
"title": {
"subscriptions": "$t(menu.subscriptions)",
"help": "$t(menu.help)",
"filters": "$t(common.filters)",
"options": "Options",
"about": "$t(menu.about)",
"post_form": "Post an information here",
"preview": "Preview",
"ask_info_form": "Ask an information here",
"contribution_details": "Detail of the contribution"
}
}
14 changes: 13 additions & 1 deletion src/i18n/resources/fr/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,16 @@
"thanks": "Merci pour votre demande.",
"message": "Elle sera très rapidement transmise au(x) source(s) concernée(s). Et vous serez prévenu de la réponse directement par mail."
}
}}
},
"title": {
"subscriptions": "$t(menu.subscriptions)",
"help": "$t(menu.help)",
"filters": "$t(common.filters)",
"options": "Options",
"about": "$t(menu.about)",
"post_form": "Poster une information ici",
"preview": "Prévisualisation",
"ask_info_form": "Demander une information ici",
"contribution_details": "Détail de la contribution"
}
}

0 comments on commit 5aa2b9f

Please sign in to comment.