material-ui-datetimepicker
material-ui-datetimepicker copied to clipboard
Changing the locale?
Hi! I just began experimenting with this component. It seems changing the locale of DatePickerDialog does not seem easy. Am I missing something here? Is there any way to accomplish this without adding new features? If not, should not it be a new feature? Neo
I managed to make it work using the following code segment (an example for German):
let DateTimeFormat = null;
if (areIntlLocalesSupported(['de'])) {
DateTimeFormat = global.Intl.DateTimeFormat;
} else {
const IntlPolyfill = require('intl');
DateTimeFormat = IntlPolyfill.DateTimeFormat;
require('intl/locale-data/jsonp/de');
}
Where areIntlLocalesSupported function comes from the intl-locales-supported package. Additionally, you also need the Intl.js package for the polyfill.
Finally, you can include the following props to the DateTimePicker component:
<DateTimePicker DatePicker={DatePickerDialog}
TimePicker={TimePickerDialog}
DateTimeFormat={DateTimeFormat}
locale='de'
/>