MCDatepicker icon indicating copy to clipboard operation
MCDatepicker copied to clipboard

Is there a way to i18n this datepicker ?

Open pedrosanchezpernia opened this issue 4 years ago • 2 comments

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

pedrosanchezpernia avatar Oct 03 '21 23:10 pedrosanchezpernia

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.

mikecoj avatar Oct 05 '21 12:10 mikecoj

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.

milesich avatar Oct 31 '21 15:10 milesich