I am fetching namespaces for each component from a database that store JSON and adding them via addResourceBundle
after init:
// Component
i18next.addResourceBundle('ar', 'topicNS', {
topics,
});
I would like to add these to the cache/localstorage. I am using the localStorageBackend
to cache the static JSON resources, how can I add to the cached namespaces after init?
I have tried using the resourcesToBackend
plugin, but am not sure how to make it work.
// i18n.js
backend: {
backends: [
LocalStorageBackend,
HttpApi,
resourcesToBackend((language, namespace, callback) => {
// ???????
}),
],
loadPath: `${process.env.PUBLIC_URL}/locales/{{lng}}/{{ns}}.json`,
},