i18next-calinga-backend
TypeScript icon, indicating that this package has built-in type declarations

0.10.14 • Public • Published

i18next-calinga-backend

Build Status NPM

An i18next backend to connect to the Calinga service.

Getting Started

Installation

npm install i18next-calinga-backend

Usage

import i18n from 'i18next';
import { CalingaBackend, CalingaBackendOptions } from 'i18next-calinga-backend';

...

const backendOptions: CalingaBackendOptions = {
    organization: '<YOUR_ORGANIZATION_NAME_HERE>',
    team: '<YOUR_TEAM_NAME_HERE>',
    project: '<YOUR_PROJECT_NAME_HERE>',
    apiToken: '<YOUR_PROJECTS_API_TOKEN_HERE>'
    resources: {
        en: {
            default: en
        },
        de: {
            default: de
        }
    }
};

i18n
  .use(CalingaBackend)
  .init({
    backend: backendOptions,
    ...
  });

Usage with React

For use in React or React Native also add the following lines to the init options:

react: {
    bindI18n: 'loaded';
}

Namespaces

If custom namespaces are used e.g.

i18next.init({
    ...
    ns:['myNamespace1'],
    ...
  }

these namespaces must match project names in calinga and translations will be fetched from there accordingly.

List of available languages

Available languages can be accessed at CalingaBackend.languages or by addding a handler for CalingaBackend.onLanguageChanged. If devMode is set to true in CalingaBackendOptions this list also contains a language that shows keys (cimode).

Draft translations

Set the includeDrafts option to true if your project has drafts enabled and you want so to see the pending version of your translations.

Example

For a full integration sample for nodejs including a cache have a look here.

Package Sidebar

Install

npm i i18next-calinga-backend

Weekly Downloads

7

Version

0.10.14

License

MIT

Unpacked Size

28.7 kB

Total Files

7

Last publish

Collaborators

  • calinga