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
453 stars 70 forks source link

Cannot combine local resources with backend resources #55

Closed EmanuelBenHamo closed 3 years ago

EmanuelBenHamo commented 3 years ago

Hello, I am trying to config my i18n to have local static json file: "backupMessages.json", and also to fetch other messages file from CDN, by using i18next-http-backend.

I came to this configuration but it only loads the local static file "backupMessages.json", without the files from the CDN:

Screen Shot 2021-03-14 at 10 58 55

couldn't find a way to make it work.

any help? thanks :)

adrai commented 3 years ago

the backup backend needs to be at the second position. Only if the first backend is not able to return the requested namespaces, it will fallback to the second backend

EmanuelBenHamo commented 3 years ago

@adrai I didn't understand your answer. what should be changed in this config?

I am trying to get the backup file not from the CDN, but from another folder in my project (it is local static file). I don't want to fetch the backup file from CDN, it has to be stored inside the app.

Is it possible to use backend to load local files, from another directory in the project?

adrai commented 3 years ago

if it's a react app, you have no access to the filesystem during runtime... it would be possible to have 2 different http-backends configured in a chained-backend, but I don't think this is what you are looking for

EmanuelBenHamo commented 3 years ago

all I want is to use backupMessages as fallback namespace in case loading the other namespaces from CDN will fail. It it possible? how? still couldn't understand how to get it.

Screen Shot 2021-03-14 at 11 39 01

adrai commented 3 years ago

You need to create your own backend and then chain it... https://github.com/i18next/i18next-http-backend/blob/master/example/fallback/app.js

EmanuelBenHamo commented 3 years ago

@adrai Thanks for your help! It solved my problem.

adrai commented 3 years ago

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

There are many ways to help this project 🙏