AustinGil / vuetensils

🍴 A tasty toolset for Vue.js 🛠 - Lightweight, functional components to boost your next project.
https://vuetensils.austingil.com/
MIT License
658 stars 38 forks source link

[Feature Request] allow localization of the buttons of the datepicker #134

Closed bcourtel closed 1 year ago

bcourtel commented 2 years ago

Hey there,

Thanks for your work on this library, it's really useful and easy to use. However, I have a small problem: we want to use the datepicker component on a French website, and, while the month and day labels are configurable through props, the aria-label attributes for the "previous/next month/year" buttons are not. This could be easily fixed by allowing customization through props. I'll submit a PR to fix that if you're okay with it.

Proposal: add a prop buttonLabels with the following format:

{
  selectDate: 'Select Date',
  showCalendar: 'show calendar',
  previousMonth: 'previous month',
  nextMonth: 'next month',
  previousYear: 'previous year',
  nextYear: 'next year',
}

edit: added the "Select Date" and "show calendar" buttons that I missed

AustinGil commented 2 years ago

Good catch. I really want to support i18n as much as possible. Eventually, it would be great to have translation files, but I'm only one person.

Thanks for the PR. That helps a lot!

bcourtel commented 2 years ago

I agree about translation files. If you have some idea about how to architecture it, I might be able to help you implement it

AustinGil commented 2 years ago

I really appreciate it, but I dont have an idea for the best approach, and Im not sure I have the capacity to work on it at the moment. I think it's a bit of a larger task with lower priority since most of the text is provided by users anyway. So Im not sure if there is a BIG need for it.

But then again, Im a native English speaker, so I could be missing an obvious need from other developers.

You got any thoughts on that?

bcourtel commented 2 years ago

I've used kazupon/vue-i18n on several projects before and it worked great and was easy to use, but I'm not sure it's a good idea for your library as it could result in a much larger dependency tree for user of the library who don't already use vue-i18n. Maybe a simple JSON files approach would work better and would be dependency-free. I quite like the current approach on VDate because it's straightforward and it allows users to easily change the text. I'll open a dedicated issue for it, maybe someone can chime in with a solution, and I'll try to think of one on my end ;)

AustinGil commented 2 years ago

Thanks. Yeah, I was going to suggest a new issue for this.

And I agree. I'd like to keep this project dependency free. Although I had to make an exception for vue-demi in order to support both V2 and V3.