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?

Alternative Caching with i18next

Browser caching with local storage

With i18next you can configure a cache layer to be used in the browser. It will load and cache resources from localStorage and can be used in combination with the chained backend.

import i18next from "i18next";
import ChainedBackend from "i18next-chained-backend";
import LocizeBackend from "i18next-locize-backend";
import LocalStorageBackend from "i18next-localstorage-backend";

i18next
  .use(ChainedBackend)
  .init({
    fallbackLng: "en",
    // ... your i18next config
    backend: {
      backends: [
        LocalStorageBackend,
        LocizeBackend
      ],
      backendOptions: [{
        expirationTime: 7 * 24 * 60 * 60 * 1000 // 7 days
      }, {
        projectId: "[PROJECTID]",
        apiKey: "[APIKEY]",
        version: "[VERSION]",
        referenceLng: "en"
      }]
    }
  });

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

Server side caching with filesystem

With i18next you can configure a cache layer to be used on server side. It will load and cache resources from the filesystem and can be used in combination with the chained backend.

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: [
        FsBackend,
        LocizeBackend
      ],
      backendOptions: [{
        expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days
        loadPath: './locales_cache/{{lng}}/{{ns}}.json',
        addPath: './locales_cache/{{lng}}/{{ns}}.json' // make sure the folders "locales_cache/{{lng}}" exists
      }, {
        projectId: "[PROJECTID]",
        apiKey: "[APIKEY]",
        version: "[VERSION]",
        referenceLng: "en"
      }]
    }
  });

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

React-native caching with AsyncStorage

With i18next you can configure a cache layer to be used on react-native. It will load and cache resources from the AsyncStorage and can be used in combination with the chained backend.

import i18next from "i18next";
import ChainedBackend from "i18next-chained-backend";
import LocizeBackend from "i18next-locize-backend";
import AsyncStorageBackend from "i18next-async-storage-backend";

i18next
  .use(ChainedBackend)
  .init({
    fallbackLng: "en",
    // ... your i18next config
    backend: {
      backends: [
        AsyncStorageBackend,
        LocizeBackend
      ],
      backendOptions: [{
        expirationTime: 7 * 24 * 60 * 60 * 1000 // 7 days
      }, {
        projectId: "[PROJECTID]",
        apiKey: "[APIKEY]",
        version: "[VERSION]",
        referenceLng: "en"
      }]
    }
  });

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

Server side Next.js caching with filesystem

Server side Next.js caching with filesystem

Similar to the normal server side caching with filesystem, you can use the same approach in a Next.js app in combination with next-i18next. It will load and cache resources from the filesystem and can be used in combination with the chained backend.

The config file, will probably look similar to this, but for a more complete example have a look at this example.

// next-i18next.config.js
const ChainedBackend = require('i18next-chained-backend')
const FSBackend = require('i18next-fs-backend/cjs')
const LocizeBackend = require('i18next-locize-backend/cjs')

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'de'],
  },
  backend: {
    backends: [
      FSBackend,
      LocizeBackend
    ],
    backendOptions: [{ // make sure public/locales_cache/en and public/locales_cache/de exists
      loadPath: './public/locales_cache/{{lng}}/{{ns}}.json',
      addPath: './public/locales_cache/{{lng}}/{{ns}}.json',
      expirationTime: 7 * 24 * 60 * 60 * 1000 // 7 days
    }, {
      projectId: 'd3b405cf-2532-46ae-adb8-99e88d876733',
      referenceLng: 'en'
    }]
  },
  use: [ChainedBackend],
  ns: ['common', 'footer', 'second-page'], // the namespaces needs to be listed here, to make sure they got preloaded
  serializeConfig: false, // because of the custom use i18next plugin
  // debug: true,
}

More information can be found here:
next-i18next-locize example
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.