vuetensils icon indicating copy to clipboard operation
vuetensils copied to clipboard

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

Open bcourtel opened this issue 2 years ago • 5 comments

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

bcourtel avatar Jan 06 '22 10:01 bcourtel

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!

AustinGil avatar Jan 06 '22 16:01 AustinGil

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

bcourtel avatar Jan 06 '22 17:01 bcourtel

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?

AustinGil avatar Jan 06 '22 17:01 AustinGil

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 ;)

bcourtel avatar Jan 06 '22 17:01 bcourtel

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.

AustinGil avatar Jan 06 '22 18:01 AustinGil