How change language of DatePicker (months and days) in Material UI?
I tried implement localization by theme and LocalizationProvider. Locally either globally way doesn't work. https://mui.com/x/react-date-pickers/localization/
I use typescript and MUI X v6.5.0
The example provided by the link you provide only explains how set the localization for the MUI component.
The dates are being generated by dayjs. You can use adapterLocale
to set the localization of the adapter. If you set that property you'll need to import the associated locale from dayjs
.
In the following example I used Dutch, but you can swap it out for what you want to use.
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { nlNL } from "@mui/x-date-pickers/locales";
import 'dayjs/locale/nl';
export default function BasicDatePicker() {
return (
<LocalizationProvider
dateAdapter={AdapterDayjs}
adapterLocale="nl"
localeText={
nlNL.components.MuiLocalizationProvider.defaultProps.localeText
}
>
<DatePicker views={['month']} />
</LocalizationProvider>
);
}