thisbeyond / solid-select

The Select component for Solid.
https://solid-select.com
MIT License
172 stars 18 forks source link

added customCreateLabel config property for i18n #40

Closed bniwredyc closed 2 months ago

bniwredyc commented 1 year ago

Hi, I need to display the "Create" text in different languages, what do you think about this simple solution?

martinpengellyphillips commented 1 year ago

Interesting. I'm not sure about adding an extra option for this as it raises the question of what else should be an option. I don't want a 100 line helper to become a config nightmare over time.

Some possible alternative approaches:

  1. Decompose more of the logic to make it easier to build your own helper. Perhaps overkill for a simple string change, but might help more in the longterm.
  2. Add a more generic control over label formatting. This could be making the getLabel private function overridable. Impacts key option potentially.
  3. Extend interface of createable function to allow returning custom label. Hard to differentiate from returning any value though.

I'm kinda leaning towards 1. but will think on it more. Happy to hear arguments for just adding the config option though!

bniwredyc commented 1 year ago

Hi! Totally understand your point. I'll think about how to implement a better solution. Argument for just adding the config option is it just works :) But, as you said, it's a little bit dirty and will potentially lead to an API change in the future.

martinpengellyphillips commented 1 year ago

Yeah. One additional thought - the reason for this is translation but not all languages would be a simple prefix word change.

bniwredyc commented 8 months ago

@martinpengellyphillips so I thought about a better solution, but haven't found any yet :D Maybe use my simple solution for now? It makes solid-select i18n compatible for most cases. I promise to help if we find more complex case where it doesn't work. What do you think?

Hentioe commented 5 months ago

It feels more appropriate to add the locale option, because this component actually has more than just Create text. An internal dictionary corresponding to the locale can be easily processed, what do you think?

bniwredyc commented 3 months ago

@Hentioe the thing is you can change all the labels now except Create, this is more flexible solution than internal dictionary imo

martinpengellyphillips commented 2 months ago

This will be possible in the next release, but using a different approach so closing this PR now. See #58 to follow along.