nolanlawson / emoji-picker-element

A lightweight emoji picker for the modern web
https://nolanlawson.github.io/emoji-picker-element/
Apache License 2.0
1.49k stars 86 forks source link

Unify language codes in the i18n file names. #395

Open dariuszdawidowski opened 10 months ago

dariuszdawidowski commented 10 months ago

I think it would be better to use ISO language codes for all file names in emoji-picker-element/i18n/*.js so it would be easy to use with window.navigator.language. At this moment some of them has double ISO name like pt_BR, some not like: pl, en, etc.

nolanlawson commented 10 months ago

Yeah this is a historical result of which languages folks decided to add translations for. And some of the translators decided to specify e.g. Brazilian Portuguese rather than just Portuguese. (I'm not an expert on Portuguese, so I deferred to the translator's judgment.)

There is also some trickiness with "languages" with vastly different writing systems or vocabulary. Like we have zh_CN but if we had traditional Chinese or Cantonese it would probably look very different.

nolanlawson commented 10 months ago

BTW this would be a breaking change. Assuming what you're asking for is for all the language codes to just be the two-letter version and not the double ISO names?

dariuszdawidowski commented 10 months ago

BTW this would be a breaking change. Assuming what you're asking for is for all the language codes to just be the two-letter version and not the double ISO names?

I think double ISO names are better. Broser variable window.navigator.language already contains double name (but with dash not underscore) this could be used directly to initialize language.

akkie commented 7 months ago

You should differentiate here between language and locale. An iso language code is a two letter code like "de", "en" and so on. A locale code consists of a language and a country (region). This is needed to distinguish between countries and languages. As example english is spoken in multiple countries. So as example we have en-GN and en-US. If you now want to display special units for number values, there might be different rules for US and GB. Therefore a locale is needed here. If you only want to translate things without applying special rules to numbers or dates, ..., the two character language code is enough. Regarding a underscore or hyphen in locale codes. Based on RFC 4646 the hyphen is the standard. But codes with underscore are also used frequently.