1
1
import { Box } from '@mui/material' ;
2
- import { DataGrid , DataGridProps , GridColumns , GridFilterItem , GridLinkOperator } from '@mui/x-data-grid' ;
3
- import React , { useCallback , useEffect , useState } from 'react' ;
2
+ import { DataGrid , DataGridProps , enUS , frFR , GridColumns , GridFilterItem , GridLinkOperator } from '@mui/x-data-grid' ;
3
+ import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
4
4
import { useTranslation } from 'react-i18next' ;
5
5
import { useAlert } from '../hooks/useAlert' ;
6
+ import { useLanguage } from '../hooks/useLanguage' ;
6
7
import { GlobalCsvExport } from './DatatableGlobalExport' ;
7
8
import DatatableToolbar from './DatatableToolbar' ;
8
9
@@ -43,6 +44,7 @@ const Datatable = <DataType extends WithId, Model>({
43
44
} : DatatableProps < DataType , Model > ) => {
44
45
const Alert = useAlert ( ) ;
45
46
const { t } = useTranslation ( 'table' ) ;
47
+ const { language } = useLanguage ( ) ;
46
48
47
49
const [ isLoading , setLoading ] = useState ( true ) ;
48
50
const [ page , setPage ] = useState ( 0 ) ;
@@ -53,6 +55,8 @@ const Datatable = <DataType extends WithId, Model>({
53
55
const [ filtersOperator , setFiltersOperator ] = useState < GridLinkOperator > ( GridLinkOperator . And ) ;
54
56
const [ data , setData ] = useState < DataType [ ] > ( [ ] ) ;
55
57
58
+ const localeText = useMemo ( ( ) => ( language === 'fr' ? frFR : enUS ) . components . MuiDataGrid . defaultProps . localeText , [ language ] ) ;
59
+
56
60
const tableOptions : Omit < DataGridProps , 'columns' | 'rows' > = {
57
61
autoHeight : true ,
58
62
checkboxSelection : true ,
@@ -199,6 +203,7 @@ const Datatable = <DataType extends WithId, Model>({
199
203
} }
200
204
>
201
205
< DataGrid
206
+ localeText = { localeText }
202
207
experimentalFeatures = { { newEditingApi : true } }
203
208
columns = { columns }
204
209
components = { {
0 commit comments