Nominal Pizza Masticator
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

locize

1.2.0 • Public • Published

Travis Coveralls npm version Bower David

locize.js

locize.js is a prebundled i18next client to use in the browser. It bundles i18next, the language detector and the locize backend.

Getting started

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

# npm package
$ npm install locize

# bower
$ bower install locize
import locize from 'locize';

locize.init({
  lng: 'en',
  backend: {
    projectId: '[PROJECT_ID]',
    apiKey: '[API_KEY]',
    referenceLng: 'en'
  }
}, (err, t) => {
  // initialized and ready to go!
  const hw = locize.t('key'); // hw = 'hello world'
});

For more information visit the i18next website:

Get project languages

To build some dynamic language selector you can load the available languages:

locize.getLanguages(function(err, lngs) {
  console.warn(lngs);
});
 
// returns something like
{
  "en": {
    "name": "English",
    "nativeName": "English",
    "translated": {
       "latest": 1,
       "production": 1
     }
  },
  "de": {
    "name": "German",
    "nativeName": "Deutsch",
    "translated": {
       "latest": 0.8,
       "production": 1
     }
  }
}

install

npm i locize

Downloadsweekly downloads

74

version

1.2.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability