make the LineChart component translatable

This commit is contained in:
Dawid Wysokiński 2020-12-06 14:21:25 +01:00
parent 372700ce2b
commit eccaf07590
6 changed files with 27 additions and 13 deletions

View File

@ -1,4 +1,6 @@
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next';
import { LINE_CHART } from '@config/namespaces';
import { darkTheme } from './theme'; import { darkTheme } from './theme';
import { ResponsiveLine, LineSvgProps } from '@nivo/line'; import { ResponsiveLine, LineSvgProps } from '@nivo/line';
@ -11,6 +13,8 @@ export interface Props extends LineSvgProps {
} }
const LineChart = ({ data, loading, ...rest }: Props) => { const LineChart = ({ data, loading, ...rest }: Props) => {
const { t } = useTranslation(LINE_CHART);
if (loading) { if (loading) {
return <Skeleton height="100%" variant="rect" />; return <Skeleton height="100%" variant="rect" />;
} }
@ -24,7 +28,7 @@ const LineChart = ({ data, loading, ...rest }: Props) => {
alignItems="center" alignItems="center"
> >
<Typography variant="h4" align="center"> <Typography variant="h4" align="center">
No records to display {t('emptyDataSourceMessage')}
</Typography> </Typography>
</Box> </Box>
); );

View File

@ -1,5 +1,6 @@
export const COMMON = 'common'; export const COMMON = 'common';
export const TABLE = 'table'; export const TABLE = 'table';
export const LINE_CHART = 'line-chart';
export const INDEX_PAGE = 'index-page'; export const INDEX_PAGE = 'index-page';
export const NOT_FOUND_PAGE = 'not-found-page'; export const NOT_FOUND_PAGE = 'not-found-page';
export const SERVER_PAGE = { export const SERVER_PAGE = {

View File

@ -4,12 +4,14 @@ import indexPage from './index-page';
import notFoundPage from './not-found-page'; import notFoundPage from './not-found-page';
import serverPage from './server-page'; import serverPage from './server-page';
import table from './table'; import table from './table';
import lineChart from './line-chart';
const translations = { const translations = {
[NAMESPACES.COMMON]: common, [NAMESPACES.COMMON]: common,
[NAMESPACES.INDEX_PAGE]: indexPage, [NAMESPACES.INDEX_PAGE]: indexPage,
[NAMESPACES.NOT_FOUND_PAGE]: notFoundPage, [NAMESPACES.NOT_FOUND_PAGE]: notFoundPage,
[NAMESPACES.TABLE]: table, [NAMESPACES.TABLE]: table,
[NAMESPACES.LINE_CHART]: lineChart,
...serverPage, ...serverPage,
}; };

View File

@ -0,0 +1,5 @@
const translations = {
emptyDataSourceMessage: 'No records to display',
};
export default translations;

View File

@ -1,19 +1,16 @@
const translations = { const translations = {
title: 'Strona główna', title: 'Home',
header: { header: {
search: 'Szukaj', search: 'Search',
}, },
serverSelection: { serverSelection: {
numberOfPlayers_0: '{{num}} gracz', numberOfPlayers: '{{num}} player',
numberOfPlayers_1: '{{num}} graczy', numberOfPlayers_plural: '{{num}} players',
numberOfPlayers_2: '{{num}} graczy', numberOfTribes: '{{num}} tribe',
numberOfTribes_0: '{{num}} plemię', numberOfTribes_plural: '{{num}} tribes',
numberOfTribes_1: '{{num}} plemiona', numberOfVillages: '{{num}} village',
numberOfTribes_2: '{{num}} plemion', numberOfVillages_plural: '{{num}} villages',
numberOfVillages_0: '{{num}} wioska', updated: 'Updated',
numberOfVillages_1: '{{num}} wioski',
numberOfVillages_2: '{{num}} wiosek',
updated: 'Zaktualizowany',
}, },
}; };

View File

@ -0,0 +1,5 @@
const translations = {
emptyDataSourceMessage: 'Brak danych do wyświetlenia',
};
export default translations;