locale
locale copied to clipboard
best() returning traditional chinese when it should be returning simplified chinese
My supported locales are:
["en", "fr", "de", "zh-hant", "zh-hans"]
In Chrome my language settings are:
My current accept-language header is:
zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4,en-US;q=0.2
After the following code:
locales = new locale.Locales(req.headers["accept-language"]);
bestLocale = (locales.best(supportedLocales) || "").toString();
bestLocale is "zh-hant"
, rather than "zh-hans"
, and traditional chinese is what's shown to the user. In the meantime I'm manually returning "zh-hans" when the first language in the header is zh-CN.
I suspect this is because the code has no way of mapping zh-CN
and zh-TW
to zh-hant
and zh-hans
so it's actually matching zh
from your browser and giving the first zh-*
from your supported list.