Skip to main content

Travis npm version Bower David

This is an i18next backend to be used for locize service. It will load resources from locize server using xhr.

It will allow you to save missing keys containing both default value and context information by calling:

i18next.t(key, defaultValue, tDescription);
i18next.t(key, { defaultValue, tDescription });

Getting started

Source can be loaded via npm, bower or downloaded from this repo.

# npm package
$ npm install i18next-locize-backend

# bower
$ bower install i18next-locize-backend

Wiring up:

import i18next from 'i18next';
import Locize from 'i18next-locize-backend';

i18next
  .use(Locize)
  .init(i18nextOptions);
  • As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
  • If you don’t use a module loader it will be added to window.i18nextLocizeBackend

Backend Options

{
  // the id of your locize project
  projectId: '[PROJECTID]',

  // add an api key if you want to send missing keys
  apiKey: '[APIKEY]',

  // the reference language of your project
  referenceLng: '[LNG]',

  // version - defaults to latest
  version: '[VERSION]'
}

Options can be passed in:

preferred - by setting options.backend in i18next.init:

import i18next from 'i18next';
import Locize from 'i18next-locize-backend';

i18next
  .use(Locize)
  .init({
    backend: options
  });

on construction:

  import Locize from 'i18next-locize-backend';
  const locize = new Locize(null, options);

via calling init:

  import Locize from 'i18next-locize-backend';
  const locize = new Locize();
  locize.init(null, options);