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
454 stars 71 forks source link

Update readme of loadPath #35

Closed imustafin closed 3 years ago

imustafin commented 3 years ago

This PR is more like a question, but also updates the documentation.

The loadPath config takes a function (lngs, namespaces) => path. Both arguments are arrays but it is not clear when can they have more than one element.

My guess is that this happens only when multiloading is enabled. Is this true? If so, the relationship between loadPath and allowMultiLoading can be mentioned more explicitly (this PR).

I've checked the codes of i18next-http-backend, i18next itself, i18next-multiload-adapter but couldn't find the answer to this question.

Checklist

adrai commented 3 years ago

Yes, but the important part is, it's always an array, no matter if there is just 1 element or 10 elements. The loading behaviour of i18next could change in future... for example by some sort of progressive loading or whatever...

imustafin commented 3 years ago

I see, thanks for your answer. I think if the loading behaviour will change as you said, it will be a breaking change anyways, considering that the recommended approach is to just serve json files directly (https://react.i18next.com/latest/using-with-hooks#translation-files) which means that interpolating languages.join('+') into the default loadPath will not work.

Until then, I think it can be documented (or assumed) that without multiloading, there will be only one lng and only one ns.