Reputation: 663
I have a question for the i18next library. If I have these set of locales that are possible to be detected from the browser,
de
en-US
es
fr
it
ja
ko
pt-br
zh-cn
zh-tw
Is there a way to configure it where it respects the language only for some locales and not the other? for example, when it comes to en-US
, I wish for the loaded language to be en
so when I call the .language
or .languages
method, it will contain en
instead of en-US
. However, for the other locales that have a dash like pt-br
, zh-cn
, and zh-tw
, they will remain untouched, (so NOT return just zh
).
Is this possible?
thanks in advance!
Upvotes: 0
Views: 657
Reputation: 3168
Yes, make use of the configuration options: https://www.i18next.com/overview/configuration-options
With the load option set to "all", it will first check for "en-US" and if not found, it will use "en"... and the i18next.resolvedLanguage
value will be "en"
There are also other configuration options, like supportedLngs, or fallbackLng you could use to tune your use case.
Upvotes: 3