tabuckner / material-dayjs-adapter

A MatDateAdapter for Dayjs
https://www.npmjs.com/package/@tabuckner/material-dayjs-adapter
15 stars 24 forks source link

Localization #1

Closed vanrossumict closed 4 years ago

vanrossumict commented 4 years ago

Hi tabuckner! Thanks for sharing your work. A nice step in replacing MomentJs with the much lighter DayJS! I took the liberty to implement localization to this Angular Material DateAdapter. Hope you are able to review/test it and of course that you like it and merge it :)

tabuckner commented 4 years ago

@vanrossumict Thank you so much for submitting this! Taking a look now. 😄

vanrossumict commented 4 years ago

Hi tabuckner, It was a pleasure On the one hand I also think adding a shouldUseLocale option to the configuration is a good plan. I was also thinking about that. You can keep the bundle size insanely small. The solution for this might be really simple: instead of the "L" date fromat, you can use "MM/DD/YYYY" which is the default format of the en_US locale that is set by Angular Material. And of course some way of lazy loading the plugins. Btw: you can override this format by injecting your own MAT_DAYJS_DATE_FORMATS right? On the other hand, this might overcomplicate things. I have noticed that adding these 3 extra plugins do not increase the bundle size that much. The plugins are also pretty lean. The size starts to really grow when you start adding locales but that's outside of this library. Let me know what you think. I might have some time this weekend to do some coding and testing. Looking forward to your suggestions!

tabuckner commented 4 years ago

The solution for this might be really simple: instead of the "L" date fromat, you can use "MM/DD/YYYY" which is the default format of the en_US locale that is set by Angular Material. And of course some way of lazy loading the plugins. Btw: you can override this format by injecting your own MAT_DAYJS_DATE_FORMATS right?

YES! Great idea. Implementing today.

On the other hand, this might overcomplicate things. I have noticed that adding these 3 extra plugins do not increase the bundle size that much. The plugins are also pretty lean. The size starts to really grow when you start adding locales but that's outside of this library. Let me know what you think.

Okay, I'll trust you on this. Will merge the remaining changes today, and then work on the next step that I think we're on the same page for.

@vanrossumict Dude, seriously. Thank you for this work--awesome!

vanrossumict commented 4 years ago

You're most welcome. I hope to have some time soon to finish this off. Btw: I've request this project to be listed on the documentation page of Angular Material, let's hope they do it so this project gets some more attention: https://github.com/angular/components/issues/18337