Date and Time Pickers - Localization
Date and Time Pickers support translations between languages.
As with all MUI components, you can modify text and translations inside the Date and Time Pickers. You can find all the translation keys supported in the source in the GitHub repository.
The default locale of MUI is English (United States). If you want to use other locales, follow the instructions below.
Set translations globally
Using the theme
To translate all your components from @mui/x-date-pickers
and @mui/x-date-pickers-pro
,
you just have to import the locale from @mui/x-date-pikers
(see the list of supported locales below).
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { deDE } from '@mui/x-date-pickers/locales';
const theme = createTheme(
{
palette: {
primary: { main: '#1976d2' },
},
},
deDE, // use 'de' locale for UI texts (start, next month, ...)
);
function App({ children }) {
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
}
Note that createTheme
accepts any number of arguments.
If you are already using the translations of the core components or the translations of the data grid, you can add deDE
as a new argument.
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { deDE as dataGridDeDE } from '@mui/x-data-grid';
import { deDE as coreDeDE } from '@mui/material/locale';
import { deDE } from '@mui/x-date-pickers/locales';
const theme = createTheme(
{
palette: {
primary: { main: '#1976d2' },
},
},
deDE, // x-date-pickers translations
dataGridDeDE, // x-data-grid translations
coreDeDE, // core translations
);
function App({ children }) {
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
}
Using LocalizationProvider
If you want to pass language translations without using createTheme
and ThemeProvider
,
you can directly load the language translations from the @mui/x-date-pickers
or @mui/x-date-pickers-pro
package and pass them to the LocalizationProvider
.
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { deDE } from '@mui/x-date-pickers/locales';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
<LocalizationProvider
localeText={deDE.components.MuiLocalizationProvider.defaultProps.localeText}
>
<DatePicker />
</LocalizationProvider>;
Set translations locally
You can also customize the translations of a single component.
If you want to customize some translations on specific component, you can use the localeText
prop exposed by all our pickers.
<DatePicker localeText={{ clearButtonLabel: 'Empty' }} />
Supported locales
Locale | BCP 47 language tag | Import name | Completion | Related file |
---|---|---|---|---|
Belarusian | be-BY | beBY | 35/36 | Edit |
Catalan | ca-ES | caES | 36/36 | Edit |
Chinese (Simplified) | zh-CN | zhCN | 36/36 | Edit |
Czech | cs-CZ | csCZ | 35/36 | Edit |
Danish | da-DK | daDK | 36/36 | Edit |
Dutch | nl-NL | nlNL | 36/36 | Edit |
Finnish | fi-FI | fiFI | 24/36 | Edit |
French | fr-FR | frFR | 35/36 | Edit |
German | de-DE | deDE | 35/36 | Edit |
Hebrew | he-IL | heIL | 36/36 | Edit |
Hungarian | hu-HU | huHU | 35/36 | Edit |
Icelandic | is-IS | isIS | 24/36 | Edit |
Italian | it-IT | itIT | 35/36 | Edit |
Japanese | ja-JP | jaJP | 36/36 | Edit |
Kazakh | kz-KZ | kzKZ | 35/36 | Edit |
Korean | ko-KR | koKR | 35/36 | Edit |
Norwegian (bokmål) | nb-NO | nbNO | 28/36 | Edit |
Persian | fa-IR | faIR | 36/36 | Edit |
Polish | pl-PL | plPL | 28/36 | Edit |
Portuguese (Brazil) | pt-BR | ptBR | 36/36 | Edit |
Russian | ru-RU | ruRU | 35/36 | Edit |
Slovak | sk-SK | skSK | 35/36 | Edit |
Spanish | es-ES | esES | 36/36 | Edit |
Swedish | sv-SE | svSE | 28/36 | Edit |
Turkish | tr-TR | trTR | 36/36 | Edit |
Ukrainian | uk-UA | ukUA | 35/36 | Edit |
Urdu (Pakistan) | ur-PK | urPK | 28/36 | Edit |
You can find the source in the GitHub repository.
To create your own translation or to customize the English text, copy this file to your project, make any changes needed and import the locale from there. Note that these translations of the date and time picker components depend on the Localization strategy of the whole library.