svelte-datepicker
svelte-datepicker copied to clipboard
Localization of Dates
We would really love to show the datepicker in german to our customers.
I just had a look at the current implementation, and it seems quite hard to do this currently, as dayjs is fairly limited in locale support. I mean, yes they have many locales, but i don't see a way how we could use this functionality currently.
Their doc says that we should import the local we want to use: https://day.js.org/docs/en/i18n/loading-into-nodejs
import 'dayjs/locale/de' // ES 2015
dayjs.locale('de') // use locale globally
But in my opinion this is useless for us, because we would need to dynamically import the language, or alternatively import every local, which would be a very bad idea. I had a look at Stackoverflow but I did not get the dynamic import to work.
I currently don't see a way how we could implement this quite well, thats why I would suggest that we switch the datelibary to something thats support our needs. Currently I have luxon in mind, which also uses the Intl API from browsers to support such a stuff. Have a look here for a locale example
What is your opinion about that? Do you have any other ideas what we should try instead? Did I miss something?
I need to have a play with importing locales. At worst, we could just pass in the dayjs instance to the calendar. That wouldn't be so bad.
The problem with luxon, moment and their ilk is that they are absolutely massive, whereas dayjs is just 2kb.
One of the main reasons I switched the calendar to days is internationalisation, so it would be a shame if that didn't work.
Lets have a play with importing the locale and see what we get to.