Closed grug closed 4 months ago
Please provide a minimal reproducible example repository like for example here: https://github.com/i18next/i18next-http-middleware/tree/master/example/basic
btw: it seems you have not defined the caches option: https://github.com/i18next/i18next-http-middleware?tab=readme-ov-file#detector-options
I made a repro repo and in doing so everything worked properly so it must be something with my project setup and not this library. I'll link the repo here anyways as maybe it might be useful to someone: https://github.com/grug/i18next-language-bug-repro
I'll close this now - sorry that this turned out to be a waste of time!
+1
🐛 Bug Report
It seems that no matter how the language detector is configured, English is always being used.
To Reproduce
I've got two sets of translation files (one for English and one for Welsh) in the right place.
I have initialised things like this
At this point, I'd have thought specifying
lng
in the URL would allow me to switch between English and Welsh (i.e.localhost:8000?lng=en
gives English andlocalhost:8000?lng=cy
gives Welsh). However, it just gives English either way.I then tried explicitly setting
lng: 'cy'
in my init block to make sure it could successfully load the Welsh translations and that I hadn't done something silly - which loaded Welsh fine. So at this point I can't switch languages via URL.I then added the following block right after my init code to set a cookie-specified language to Welsh:
At this point I can see the cookie is set on the client correctly (right name and a value of
cy
) but the language being shown is still English.I then tried setting the browser's language to Welsh, hoping that this would affect things, but it also didn't.
I have no other middleware in the project that could interfere with this, so I imagine it's a configuration issue, or a bug.
Expected behavior
I'd expect that given the configuration options that I'd set in my code, that I could switch between languages using the URL/cookies/setting the accept-language header.
Your Environment