MCDatepicker
MCDatepicker copied to clipboard
Is there a way to i18n this datepicker ?
I would like to present the interface in several languages, but I didn't see how to deal with that in the issues/docs or if it is even possible at all? Thanks for any tips, Pedro
Hello Pedro,
This component doesn't support i18n at this moment, but using options: customWeekDays and customMonths can help you change weekdays and months names programmatically.
You can use something like this. It would show months and weekdays in the browser locale:
var weekdays = [];
for (var d = 7; d < 14; d++) {
weekdays.push((new Date(2021, 10, d)).toLocaleString([], {weekday: "long"}));
}
var months = [];
for (var m = 0; m < 12; m++) {
months.push((new Date(2021, m, 1)).toLocaleString([], {month: "long"}));
}
var datepicker = MCDatepicker.create({
...
customWeekDays: weekdays,
customMonths: months,
...
});
The first param to .toLocaleString() accepts locale so to have calendar in Spanish use es_ES or French with fr_FR.