i18next / i18next-gitbook

165 stars 172 forks source link

API docs for i18next.languages is not very specific #53

Closed kevin-lindsay-1 closed 6 years ago

kevin-lindsay-1 commented 6 years ago

I had to read the source code to determine how i18next.languages is set and used; I can make a PR if preferred, but I'm not 100% confident that my documentation will be technically accurate, as I've only spent a few minutes reading the code.

I am considering rewriting it as such:

i18next.languages Is set to an array of language-codes that will be used in order to lookup the translation value. When the language is set, this array is populated with the new language code, which by default falls back to the less specific versions ("en-US-xx", "en-US", "en"), followed by the list of fallback codes. Values are unique, so if they appear earlier in the array, they will not be added again.

Example: > i18next.init({ fallbackLng: ["es", "fr", "en-US"] }) > i18next.changeLanguage("en-US-xx") > i18next.languages > ["en-US-xx", "en-US", "en", "es", "fr"]

Please let me know your thoughts.

jamuhl commented 6 years ago

yes...go for it...every improvement that makes it more understandable is very welcome...

kevin-lindsay-1 commented 6 years ago

Okay, I will read further and make a PR.