Search result not found.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

On this page

Locize Docs

Introduction

Using locize

Integration

Guides / Tips & Tricks

More

Which integration option should I use?Do I have to use the locize CDN or can I host / bundle the translations directly?How is locize different from the alternatives?Why do I get “The passed json is nested too deeply.” when consuming the API?Is locize only for developers and translators or is project management within the process too?What is the regular way to update the translation memory?Is there any visibility on project’s level of completion that shows how translators are progressing?Why is my namespace suddenly a flat json?How to change the publish format?Why does my namespace contain an array with a lot of null items?Why is the pricing so complicated?How to change credit card or billing information or download the invoices?How to import translations from a file?How to manually publish a specific version?How to delete or rename a namespace?Why is there such a high download amount?Where do I find the namespace backups?How can a segment/key be copied/moved or renamed?Why a new namespace is created, when I upload a translation file?I want to use the locize CDN, but would like to have a fallback that uses local/bundled translationsIs it possible to integrate multiple projects in the same app/website?Why do I see strange new keys marked as ONE, FEW, MANY, OTHERS?How do I open and edit JSON files?i18n vs. i18nexti18next vs. locizeWord CounterHow to style text within locize?What do I have to consider if my translation texts may contain confidential information?How to translate a file and download the results?

Backend Fallback

Do you want to define a fallback which uses local translations?

Browser fallback with local / bundled translations

With i18next you can configure a fallback backend to be used in the browser. It will try to load from your primary backend (in this case from your locize backend) and if the primary backend is not reachable or does not serve translations, your second backend (in this case local or bundled translations) will be used. This is all possible thanks to the chained backend.

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

import i18next from "i18next";
import ChainedBackend from "i18next-chained-backend";
import LocizeBackend from "i18next-locize-backend";
import resourcesToBackend from "i18next-resources-to-backend";

i18next
  .use(ChainedBackend)
  .init({
    fallbackLng: "en",
    // ... your i18next config
    backend: {
      backends: [
        LocizeBackend,
        resourcesToBackend((lng, ns) => import(`./locales/${lng}/${ns}.json`))
      ],
      backendOptions: [{
        projectId: "[PROJECTID]",
        apiKey: "[APIKEY]",
        version: "[VERSION]",
        referenceLng: "en"
      }]
    }
  });

More information can be found here:
i18next-chained-backend
i18next-resources-to-backend
i18next-locize-backend

Server side fallback with filesystem

On server side you can also use the i18next-fs-backend for example instead of the in memory fallback.

import i18next from "i18next";
import ChainedBackend from "i18next-chained-backend";
import LocizeBackend from "i18next-locize-backend";
import FsBackend from "i18next-fs-backend";

i18next
  .use(ChainedBackend)
  .init({
    fallbackLng: "en",
    // ... your i18next config
    backend: {
      backends: [
        LocizeBackend,
        FsBackend
      ],
      backendOptions: [{
        projectId: "[PROJECTID]",
        apiKey: "[APIKEY]",
        version: "[VERSION]",
        referenceLng: "en"
      }, {
        loadPath: './locales_cache/{{lng}}/{{ns}}.json'
      }]
    }
  });

More information can be found here:
i18next-chained-backend
i18next-fs-backend
i18next-locize-backend

We suggest not to use multiple backends with the i18next-chained-backend in combination with saveMissing or updateMissing, because it may happen, that the trigger for this is based on stale data.