Skip to content

Commit

Permalink
[DataGrid] Add missing TablePagination localizations (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanailH authored Feb 26, 2021
1 parent 9e1589e commit 4be9476
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/grid/_modules_/grid/components/GridPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export function GridPagination() {
: []
}
rowsPerPage={paginationState.pageSize}
labelRowsPerPage={apiRef!.current.getLocaleText('footerPaginationRowsPerPage')}
{...getPaginationChangeHandlers()}
/>
);
Expand Down
3 changes: 0 additions & 3 deletions packages/grid/_modules_/grid/constants/localeTextConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,4 @@ export const GRID_DEFAULT_LOCALE_TEXT: GridLocaleText = {

// Total rows footer text
footerTotalRows: 'Total Rows:',

// Pagination footer text
footerPaginationRowsPerPage: 'Rows per page:',
};
9 changes: 5 additions & 4 deletions packages/grid/_modules_/grid/locales/bgBG.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { bgBG as bgBGCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';

export const bgBG: Localization = getGridLocalization({
const bgBGGrid: Partial<GridLocaleText> = {
// Root
rootGridLabel: 'мрежа',
noRowsLabel: 'Няма редове',
Expand Down Expand Up @@ -75,7 +77,6 @@ export const bgBG: Localization = getGridLocalization({

// Total rows footer text
footerTotalRows: 'Общо Rедове:',
};

// Pagination footer text
footerPaginationRowsPerPage: 'Редове на страница:',
});
export const bgBG: Localization = getGridLocalization(bgBGGrid, bgBGCore);
3 changes: 2 additions & 1 deletion packages/grid/_modules_/grid/locales/enUS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { enUS as enUSCore } from '@material-ui/core/locale';
import { getGridLocalization, Localization } from '../utils';
import { GRID_DEFAULT_LOCALE_TEXT } from '../constants/localeTextConstants';

export const enUS: Localization = getGridLocalization(GRID_DEFAULT_LOCALE_TEXT);
export const enUS: Localization = getGridLocalization(GRID_DEFAULT_LOCALE_TEXT, enUSCore);
9 changes: 5 additions & 4 deletions packages/grid/_modules_/grid/locales/frFR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { frFR as frFRCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';

export const frFR: Localization = getGridLocalization({
const frFRGrid: Partial<GridLocaleText> = {
// Root
rootGridLabel: 'grid',
noRowsLabel: 'Pas de résultats',
Expand Down Expand Up @@ -77,7 +79,6 @@ export const frFR: Localization = getGridLocalization({

// Total rows footer text
footerTotalRows: 'Lignes totales :',
};

// Pagination footer text
footerPaginationRowsPerPage: 'Lignes par page :',
});
export const frFR: Localization = getGridLocalization(frFRGrid, frFRCore);
9 changes: 5 additions & 4 deletions packages/grid/_modules_/grid/locales/ptBR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ptBR as ptBRCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';

export const ptBR: Localization = getGridLocalization({
const ptBRGrid: Partial<GridLocaleText> = {
// Root
rootGridLabel: 'Grade',
noRowsLabel: 'Nenhuma linha',
Expand Down Expand Up @@ -77,7 +79,6 @@ export const ptBR: Localization = getGridLocalization({

// Total rows footer text
footerTotalRows: 'Total de linhas:',
};

// Pagination footer text
footerPaginationRowsPerPage: 'Linhas por página:',
});
export const ptBR: Localization = getGridLocalization(ptBRGrid, ptBRCore);
3 changes: 0 additions & 3 deletions packages/grid/_modules_/grid/models/api/gridLocaleTextApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ export interface GridLocaleText {

// Total rows footer text
footerTotalRows: React.ReactNode;

// Pagination footer text
footerPaginationRowsPerPage: React.ReactNode;
}

export type LocaleTextValue = string | React.ReactNode | Function;
Expand Down
11 changes: 8 additions & 3 deletions packages/grid/_modules_/grid/utils/getGridLocalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,29 @@ export interface LocalizationV5 {

export type Localization = LocalizationV4 | LocalizationV5;

export const getGridLocalization = (translations: Partial<GridLocaleText>): Localization => {
export const getGridLocalization = (
gridTranslations: Partial<GridLocaleText>,
coreTranslations,
): Localization => {
if (isMuiV5()) {
return {
components: {
MuiDataGrid: {
defaultProps: {
localeText: translations,
localeText: gridTranslations,
},
},
...coreTranslations.components,
},
};
}

return {
props: {
MuiDataGrid: {
localeText: translations,
localeText: gridTranslations,
},
...coreTranslations.props,
},
};
};

0 comments on commit 4be9476

Please sign in to comment.