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

loadPath arguments in custom request function #120

Closed mi-col closed 1 year ago

mi-col commented 1 year ago

🚀 Feature Proposal

I would like to be able to have arguments of the loadPath function available as parameters in the request function.

Motivation

In the case of unusual or strict APIs that don't fall under the url that can be constructed via the loadPath function, I would like to have its arguments be passed into the custom request function so that I can manage any scenario specific to the localization API that I am using.

Example

In case the API I am using has strict requirements on multiple namespaces being passed in query params as namespace=first&namespace=second rather than ns=first+second, if I retrieve different locales from different APIs or any other unusual scenario requiring a fine-tuned approach.

adrai commented 1 year ago

The custom request function should only be aware of http specific information. Alternatively, You can parse the url and extract the language and namespace information there...

mi-col commented 1 year ago

That's what I ended up doing, encoding them in loadPath and parsing in request, was simply wondering if a cleaner solution is possible.

adrai commented 1 year ago

Currently that's the only way. But If there are more users requesting this, we might do something...

mi-col commented 1 year ago

No problem, thanks for clarifying