i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
443 stars 67 forks source link

Add language to `customHeaders` parameter #115

Closed michalvadak closed 1 year ago

michalvadak commented 1 year ago

🚀 Feature Proposal

Provide language to customHeaders parameter in options to be able to append it to Accept-language header.

Example

customHeaders: (lng) => ({
        'Accept-language': lng,
})
adrai commented 1 year ago

This should normally already be sent by the browser... beside that, you can extend the headers via customHeaders... etc...

michalvadak commented 1 year ago

The i18next-http-backend isn't sending the Accept-language header by default...

I'm talking about the options parameter

adrai commented 1 year ago

Not the i18next-http-backend modules sets that header, but your browser will do it. Check the network tab in your browser's dev tools and inspect the request.

michalvadak commented 1 year ago

I just did and it's not there

adrai commented 1 year ago

Here the proof:

image

Just tried this example: https://github.com/i18next/i18next-http-backend/tree/master/example/jquery

You see The Accept-Language header is set to: it-IT,it;q=0.9,de;q=0.8,en-US;q=0.7,en;q=0.6

michalvadak commented 1 year ago

Yeah okay... now it's there but the language is incorrect

image
adrai commented 1 year ago

The language there is, the configured language of your browser... This is not an i18next topic sorry.