i18next-polyglot

0.1.0 • Public • Published

Introduction

Travis Coveralls npm version David

This changes i18n format from i18next json to polyglot using airbnb/polyglot.js

Getting started

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

# npm package
$ npm install i18next-polyglot

Wiring up:

import i18next from 'i18next';
import Polyglot from 'i18next-polyglot';

i18next
  .use(Polyglot)
  .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.i18nextPolyglot

Backend Options

{
  // currently there are no extra options
}

Options can be passed in by setting options.i18nFormat in i18next.init:

import i18next from 'i18next';
import Polyglot from 'i18next-polyglot';

i18next
  .use(Polyglot)
  .init({
    i18nFormat: options
  });

more complete sample

import i18next from 'i18next';
import Polyglot from 'i18next-polyglot';

i18next
  .use(Polyglot)
  .init({
    lng: 'en',
    resources: {
      en: {
        translation: {
          "hello_name": "Hola, %{name}."
        }
      }
    }
  });

 i18next.t('hello_name', { name: "DeNiro" }); // -> "Hola, DeNiro."

/i18next-polyglot/

    Package Sidebar

    Install

    npm i i18next-polyglot

    Weekly Downloads

    198

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    19.7 kB

    Total Files

    16

    Last publish

    Collaborators

    • jamuhl