I have a date field in my view which is as follows:
<input class="flatpickr flatpickr-input active_es" type="text" placeholder="Select Date.." readonly="readonly">
and a javascript where I use Flatpickr:
function form__date_register() {
flatpickr('.js--input--date_register', {
minDate: '1920-01-01',
locale: 'es',
});
}
but I can't find a way for the calendar to be in Spanish and not in English. I hope and someone can help me thanks.
You only add to your jquery the following information about the locale (locale) configuration:
I recommend putting the parameters as a separate function (example
flatParameters()
) in your js functions file that you can access globally. In this way you avoid repeating code because you would only call the functionflatParameters()
to set the language every time you use the calendar. In this way you maintain the DRY (Don't Repeat Yourself) principle that allows you to maintain good programming practices.I hope to be helpful. All the best!