From 95f8534824203efbede5ffd46c29b74a6fdfcf6a Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Sat, 7 Nov 2020 13:45:02 +0100 Subject: [PATCH] translate NotFoundPage into Polish --- src/common/Link/Link.tsx | 19 +++++++++++++++---- src/config/namespaces.ts | 1 + src/features/NotFoundPage/NotFoundPage.tsx | 12 ++++++++---- src/libs/i18n/en/index.ts | 2 ++ src/libs/i18n/en/not-found-page.ts | 7 +++++++ src/libs/i18n/pl/index.ts | 2 ++ src/libs/i18n/pl/not-found-page.ts | 7 +++++++ 7 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 src/libs/i18n/en/not-found-page.ts create mode 100644 src/libs/i18n/pl/not-found-page.ts diff --git a/src/common/Link/Link.tsx b/src/common/Link/Link.tsx index c551dac..7faba77 100644 --- a/src/common/Link/Link.tsx +++ b/src/common/Link/Link.tsx @@ -1,12 +1,23 @@ -import React from 'react'; +import React, { forwardRef, RefObject } from 'react'; import { Link as RRDLink, LinkProps as RRDLinkProps } from 'react-router-dom'; import { Link as MUILink, LinkProps as MUILinkProps } from '@material-ui/core'; export type Props = MUILinkProps & RRDLinkProps; -const CustomizedRRDLink = ({ children, ...props }: Props) => { - return {children}; -}; +const CustomizedRRDLink = forwardRef( + ( + { children, ...props }: Props, + ref: + | ((instance: HTMLAnchorElement | null) => void) + | RefObject + | null + | undefined + ) => ( + + {children} + + ) +); function Link({ children, ...props }: Props) { return ( diff --git a/src/config/namespaces.ts b/src/config/namespaces.ts index eca242b..5975c0f 100644 --- a/src/config/namespaces.ts +++ b/src/config/namespaces.ts @@ -1,2 +1,3 @@ export const COMMON = 'common'; export const INDEX_PAGE = 'index-page'; +export const NOT_FOUND_PAGE = 'not-found-page'; diff --git a/src/features/NotFoundPage/NotFoundPage.tsx b/src/features/NotFoundPage/NotFoundPage.tsx index 7917f3f..e70b5ba 100644 --- a/src/features/NotFoundPage/NotFoundPage.tsx +++ b/src/features/NotFoundPage/NotFoundPage.tsx @@ -1,5 +1,8 @@ import React from 'react'; +import { useTranslation } from 'react-i18next'; +import useTitle from '@libs/useTitle'; import { INDEX_PAGE } from '@config/routes'; +import { NOT_FOUND_PAGE } from '@config/namespaces'; import { makeStyles } from '@material-ui/core/styles'; import { Container, Typography } from '@material-ui/core'; @@ -17,20 +20,21 @@ const useStyles = makeStyles(() => ({ const NotFoundPage = () => { const classes = useStyles(); + const { t } = useTranslation(NOT_FOUND_PAGE); + useTitle(t('title')); return (
- Page Not Found + {t('title')} - Looks like you've followed a broken link or entered a URL that doesn't - exist on this site. + {t('description')} - Back to our site + {t('backToOurSite')} diff --git a/src/libs/i18n/en/index.ts b/src/libs/i18n/en/index.ts index 27769c1..1fab2cb 100644 --- a/src/libs/i18n/en/index.ts +++ b/src/libs/i18n/en/index.ts @@ -1,10 +1,12 @@ import * as NAMESPACES from '@config/namespaces'; import common from './common'; import indexPage from './index-page'; +import notFoundPage from './not-found-page'; const translations = { [NAMESPACES.COMMON]: common, [NAMESPACES.INDEX_PAGE]: indexPage, + [NAMESPACES.NOT_FOUND_PAGE]: notFoundPage, }; export default translations; diff --git a/src/libs/i18n/en/not-found-page.ts b/src/libs/i18n/en/not-found-page.ts new file mode 100644 index 0000000..5d77a66 --- /dev/null +++ b/src/libs/i18n/en/not-found-page.ts @@ -0,0 +1,7 @@ +const translations = { + title: 'Page not found', + description: `Looks like you've followed a broken link or entered a URL that doesn't exist on this site.`, + backToOurSite: 'Back to our site', +}; + +export default translations; diff --git a/src/libs/i18n/pl/index.ts b/src/libs/i18n/pl/index.ts index 27769c1..1fab2cb 100644 --- a/src/libs/i18n/pl/index.ts +++ b/src/libs/i18n/pl/index.ts @@ -1,10 +1,12 @@ import * as NAMESPACES from '@config/namespaces'; import common from './common'; import indexPage from './index-page'; +import notFoundPage from './not-found-page'; const translations = { [NAMESPACES.COMMON]: common, [NAMESPACES.INDEX_PAGE]: indexPage, + [NAMESPACES.NOT_FOUND_PAGE]: notFoundPage, }; export default translations; diff --git a/src/libs/i18n/pl/not-found-page.ts b/src/libs/i18n/pl/not-found-page.ts new file mode 100644 index 0000000..024446b --- /dev/null +++ b/src/libs/i18n/pl/not-found-page.ts @@ -0,0 +1,7 @@ +const translations = { + title: 'Nie znaleziono strony', + description: `Wygląda na to, że kliknąłeś uszkodzony link lub wpisałeś adres URL, który nie istnieje.`, + backToOurSite: 'Wróć na stronę główną', +}; + +export default translations;