Backend Fallback
Do you want to define a fallback which uses local translations?
Browser fallback with local / bundled translations
import i18next from "i18next";
import ChainedBackend from "i18next-chained-backend";
import LocizeBackend from "i18next-locize-backend";
import resourcesToBackend from "i18next-resources-to-backend";
const bundledResources = {
en: {
translation: {
key: 'value'
}
}
};
i18next
.use(ChainedBackend)
.init({
fallbackLng: "en",
// ... your i18next config
backend: {
backends: [
LocizeBackend,
resourcesToBackend(bundledResources)
],
backendOptions: [{
projectId: "[PROJECTID]",
apiKey: "[APIKEY]",
version: "[VERSION]",
referenceLng: "en"
}]
}
});You can also lazy load the in memory translations, i.e. when using webpack
Server side fallback with filesystem
Last updated