Event Calendar - Localization
The Event Calendar's localization features provide the appropriate translations for users around the world.
The default locale of MUI X is English (United States). To use other locales, follow the instructions below.
Translation keys
You can use the localeText prop to pass in your own text and translations.
You can find all the translation keys supported in the source
in the GitHub repository.
In the following example, the labels of the view switcher buttons are customized.
Alice's Birthday
Morning Run
Team Meeting
Gym Class
Yoga
1-on-1 with Sarah
Code Review
4th of July BBQ
Locale text
The default locale of MUI X is English (United States).
You can use the theme to configure the locale text:
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
import { frFR } from '@mui/x-scheduler/locales';
// Or import { frFR } from '@mui/x-scheduler-premium/locales';
const theme = createTheme(
{
palette: {
primary: { main: '#1976d2' },
},
},
frFR,
);
<ThemeProvider theme={theme}>
<EventCalendar />
</ThemeProvider>;
Note that createTheme() accepts any number of arguments.
If you are already using the translations of the core components, you can add frFR as a new argument.
The same import works for Event Calendar Premium as it's an extension of Event Calendar.
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
import { frFR } from '@mui/x-scheduler/locales';
import { frFR as pickersFrFR } from '@mui/x-date-pickers/locales';
import { frFR as coreFrFR } from '@mui/material/locale';
const theme = createTheme(
{
palette: {
primary: { main: '#1976d2' },
},
},
frFR, // x-scheduler translations
pickersFrFR, // x-date-pickers translations
coreFrFR, // core translations
);
<ThemeProvider theme={theme}>
<EventCalendar />
</ThemeProvider>;
If you want to pass language translations directly to the Event Calendar without using createTheme() and ThemeProvider, you can directly load the language translations from @mui/x-scheduler/locales.
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
import { frFR } from '@mui/x-scheduler/locales';
<EventCalendar
localeText={frFR.components.MuiEventCalendar.defaultProps.localeText}
/>;
Alice's Birthday
Morning Run
Team Meeting
Gym Class
Yoga
1-on-1 with Sarah
Code Review
4th of July BBQ
Date locale
The localeText prop only translates the UI labels (button text, menu items, etc.).
To also translate formatted dates (day names, month names, and week start day), pass a date-fns locale object.
Use the createDateLocaleTheme helper to set the date locale globally via the theme, alongside localeText translations:
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { fr } from 'date-fns/locale/fr';
import { frFR, createDateLocaleTheme } from '@mui/x-scheduler/locales';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
const theme = createTheme(
{
palette: {
primary: { main: '#1976d2' },
},
},
frFR,
createDateLocaleTheme(fr),
);
<ThemeProvider theme={theme}>
<EventCalendar />
</ThemeProvider>;
You can also pass the dateLocale prop directly to the component to override the theme value or avoid using a theme:
import { fr } from 'date-fns/locale/fr';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
<EventCalendar dateLocale={fr} />;
Alice's Birthday
Morning Run
Team Meeting
Gym Class
Yoga
1-on-1 with Sarah
Code Review
4th of July BBQ
Long Run
Supported locales
You can find the source in the GitHub repository.
| Locale | BCP 47 language tag | Import name |
|---|---|---|
| English (United States) | en-US | enUS |
| French | fr-FR | frFR |
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 Scheduler component depend on the Localization strategy of the whole library.