You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Did you try to init the chained backend instead of passing it to i18next init?
It works like this, you just have to pass the options as the second parameter as I have referenced in this issue
import i18next from "i18next";
import XHR from "i18next-xhr-backend";
import ChainedBackend from 'i18next-chained-backend';
import LocalStorageBackend from 'i18next-localstorage-backend';
const xhr = new XHR();
xhr.init(null, {
loadPath: function(language, namespace) {
return Routing.generate("api_locales", {language, namespace});
},
// allow credentials on cross domain requests
withCredentials: false
});
const localStorageBackendOptions = {
// prefix for stored languages
prefix: 'i18next_res_',
// expiration
expirationTime: 60*1000,
// language versions
versions: {}
};
const chainedBackendOptions = {
backends: [
LocalStorageBackend,
xhr,
],
// array of options in order of backends above
backendOptions: [
localStorageBackendOptions
]
};
const chainedBackend = new ChainedBackend();
chainedBackend.init(null, chainedBackendOptions); // <- pass options as second
i18next.use(chainedBackend);
...
If I instantiate my backend, this plugin doesn't work.
Not sure if this is necessary to pass in opts and constructors separately by design. If so, add to readme.
The text was updated successfully, but these errors were encountered: