Magento2 – How to Use Frontend Calendar Localization

calendarjavascriptjquerylocalisationmagento2

I'm becoming crazy with the frontend translation of the mage/calendar widget in Magento 2.
Does somebody know how to localize it?

I have a calendar that's showing up on the front (from a bought module that has a specific class for the calendar) but I've not been able to display the months/day in French.
This specific frontend calendar is a very simple inheritance of the mage/calendar widget so I don't think that's a problem.

As the calendar widget is based on the jQuery UI calendar, I've tried to translate it as it is recommended in the jquery UI doc but it does not seem to work.

I've seen in the backend, on the product edit page, that there's a translated calendar for the date attributes 'set the product as new from' and it looks like the options of the knockout input are the following:

dateFormat:"dd/MM/y"
showsTime:true
storeLocale:"fr_FR"
timeFormat: "HH:mm"

But initializing my calendar with the following options on the front does not change anything, my calendar stay in English :

initCalendar: function() {
    $(this.element).calendar({
        dateFormat: this.options.calendarDateFormat,
        minDate: this.minDate.toDate(),
        setDate: 0,
        showOn: 'button',
        storeLocale: "fr_FR"
    });
},

I think I'm missing a little something but I don't know what and I have not been able to find any clear answer on the Internet… If anybody has already solved this issue, I would be really happy to read your answer

Thanks!

Best Answer

Well, I have no idea how to solve this for the kind of implementation of the calendar I have in this module but I replaced the calendar initialized with some data-mage-init and specific object by this simple implementation and it works fine...

Related Topic