i18next / i18next-browser-languageDetector

language detector used in browser environment for i18next
MIT License
865 stars 88 forks source link

There should be a output language shorts string list in documentation #248

Closed JoshL579 closed 2 years ago

JoshL579 commented 3 years ago

Documentation issue

I'm trying to add language-detector in my react i18n, but I have to test what the output short name is since there is no documentation for the complete list of output.

For example, I support Chinese, Korean, English, but Chinese can be zh-CN, zh-hans, zh-tw, Korean can be ko, kr and Enligsh can be en-US, en-INT, etc. According to that, I'm not sure to take which string to set in i18n configuration.

In order to make sure I didn't set the wrong string as object key, I need to actually make a language environment in browser and test the actual output. (Surprisingly, I got zh-CN for Chinese but only found zh in i18n source code in line 1200 of i18next.js)

As a result, I need to set as follow and no guarantee:

resources: {
            kr: {
                translation: kr
            },
            ko: {
                translation: kr
            },
            zh: {
                translation: zh
            },
            'zh-CN': {
                translation: zh
            },
            en: {
                translation: en
            },
            'en-US': {
                translation: en
            },
        },

Motivation

Document the whole language output string list would be a great help!

jamuhl commented 3 years ago

Guess you should try to understand what things are...

en --> english en-US --> english spoken in US ("Regional")

In detail: https://www.i18next.com/principles/translation-resolution#languages

jamuhl commented 3 years ago

further with the options "supportedLngs" and "load" you can set what you like to support in your application

JoshL579 commented 3 years ago

Thank you for your comment. Understood, but what I'm trying to find is something like Commonly used IETF language tags and ISO Language Codes.

Since the LanguageDetector is developed by your team, my expectation is that you will have a complete list of IETF language tags that would output from LanguageDetector.

It is okay for me to add supportedLngs: ['zh', 'ko', 'en'], but I still worrying about what if LanguageDetector output a code which parent code is one of ['zh', 'ko', 'en'], but fallback to a wrong one within those three, since it is not an exact match. As a result, it displays to a user with the a wrong language as default, but the language that user use is actually supported by my site couldn't display by default.

Thanks for your information anyway, and please let me know if I understood wrong.

jamuhl commented 3 years ago

not the job of the detector - handling supported languages and fallbacks is done in i18next:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.