Closed Gidgidonihah closed 3 years ago
Would you like to send a Pull Request to address this? Remember to add unit tests.
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.
🐛 Bug Report
Given a header that includes
es-419
the detection regex will return a language code ofes-
with a query value of1
.To Reproduce
Make a request using the
Accept-Language
header withes-419
lower in the stack and without another locale with query value of 1:The detected language will be
es-
Note that if you supply another
q=1
value (pt-PT,pt;q=0.9,es-419;q=0.8,es;q=0.7
) that value will be correctly picked, but the query value ofes-
will also (incorrectly) be 1 making the support cascade fail.Expected behavior
es-419
is detected with a query value of0.8
Notes
I narrowed it down to the regex on this line:
https://github.com/i18next/i18next-http-middleware/blob/7f5a3eeff9fccb95f09a9ec80c720e3f8f5e0f4d/lib/languageLookups/header.js#L17
I lucked (good or bad) into finding this because I:
supportedLngs
andnonExplicitSupportedLngs
it
) as the fallback language, but surprise it was Spanishpt-PT,pt;q=0.9,it-IT;q=0.8,it;q=0.7,en-US;q=0.6,en;q=0.5,es-419;q=04,es;q=0.3
Spanish (Latin America)
as the specific version of Spanish with which to test.My Environment
Not particularly relevant, but: