ElektraInitiative / PermaplanT

https://www.permaplant.net
BSD 3-Clause "New" or "Revised" License
16 stars 13 forks source link

Language Locales #895

Open markus2330 opened 1 year ago

markus2330 commented 1 year ago

Can you also allow "," as comma? (okay if it is accepted for both German and English)

https://stackoverflow.com/questions/26890209/html-tag-input-of-type-number-and-culture-based-decimal-separator

The comma seperator in HTML5 input fields is tied to the browsers language. We could change this using the 'lang' field of the root html tag, but I don't (yet) know if and how this can be set up using react and our internationalization library.

Originally posted by @badnames in https://github.com/ElektraInitiative/PermaplanT/issues/892#issuecomment-1711932539

markus2330 commented 1 year ago

This sounds like the perfect solution? Imho it doesn't make sense to have English text but German locales, and it also makes writing error messages unnecessarily hard (as then you don't know which is the right character for the comma).

@Bushuo is there maybe a downside to setting the 'lang' field of the root html tag according to the selected language or is this maybe not even possible? We already had a similar discussion about the date fields.

@badnames did you already find a way how to actually do it (change lang according the currently selected language)?

markus2330 commented 1 year ago

@badnames wrote in https://github.com/ElektraInitiative/PermaplanT/pull/892#issuecomment-1712082686

Changing the language on the site (react i18n does apparently update the 'lang' attribute of the root element) has no consistent effect on the selected comma separator.

Ok, so seems like we don't have a solution for this approach (described in this issue) anyway? @badnames Can you tell us what exactly you tried?

Bushuo commented 1 year ago

I think we need to also change the lang attribute when the language changes.

document.documentElement.lang = i18n.language;

But I don't know if this has any downsides or implications and can't look into it right now.

badnames commented 1 year ago

I think we need to also change the lang attribute when the language changes.

I tried that yesterday, but it did not seem to have any effect.

markus2330 commented 1 year ago

@badnames please create a PR so that we see what exactly you tried.