themesberg / flowbite-datepicker

A Tailwind CSS datepicker built with vanilla JavaScript
https://flowbite.com/docs/components/datepicker/
MIT License
139 stars 43 forks source link

Can't be able to use a different locale #11

Open cotufaloschiflones opened 1 year ago

cotufaloschiflones commented 1 year ago

Hello, I'm using this plugin and and not being able to set another locale besides en which is default one. The documentation is not clear about that anyway I have tried several approachs but not succedeed, could someone provide some information about this?

thank you!

ikerib commented 1 year ago

+1

I can't figure it out how to initialize the picker with a different locale

louisfoulet commented 1 year ago

Hello,

You will find the documentation to set locales in the i18n doc i18n doc.

Exemple in my vue3 flowbite project, to add locale to datepicker :

<script setup>
import DatePicker from 'flowbite-datepicker/Datepicker';
import DatePickerLocaleFr from 'flowbite-datepicker/locales/fr';

Object.assign(DatePicker.locales, DatePickerLocaleFr);
</script>

To use a locale loaded, set language with the language code :

let datepicker = new DatePicker(datepickerEl.value, {
      todayBtnMode: 1,
      clearBtn: true,
      todayBtn: true,
      format: 'mm/dd/yyyy',
      language: 'fr',
  });
sergio-itru commented 6 months ago

need simple option for django