basic-multilang

0.0.5 • Public • Published

basic-multilang

npm version Build Status Coverage Status

Basic implemetation of multilang support for NodeJS.

Installation

npm install basic-multilang --save

Usage

Include

var I18n = require('basic-multilang');

new I18n(directory, reload = null);

Create a instance to render I18n.

Arguments
Name Type Description
directory string Translations directory.
reload function Funcion to load files. If !reload then will be used require.
Example
// Option 1
var i18n = new I18n(path.resolve(__dirname, 'i18n'));
// Option 2
var reload = require('require-reload')(require);
var i18n = new I18n(path.resolve(__dirname, 'i18n'), reload);

i81n.setLang(lang);

Set language to use.

Arguments
Name Type Description
lang string Language to set. This will be key to get el translation.
Example
i18n.setLang('es');

i81n.getLang();

Return then language to seted.

const lang = i18n.getLang();

i81n.get(key);

Return the translation for a specific key.

Arguments
Name Type Description
key string Key to get translation.
var i18n = new I18n(path.resolve(__dirname, 'i18n'));
i18n.setLang('es');
const translation = i18n.get('mysubdirectory.myfile.myphrasekey');
// in file ./i18n/mysubdirectory/myfile.js[on], get poperty myphrasekey.es.

Troubles

If you have any kind of trouble with it, just let me now by raising an issue on the GitHub issue tracker here:

https://github.com/arondn2/basic-multilang/issues

Also, you can report the orthographic errors in the READMEs files or comments. Sorry for that, English is not my main language.

Tests

npm test or npm run cover

Readme

Keywords

Package Sidebar

Install

npm i basic-multilang

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

6.64 kB

Total Files

8

Last publish

Collaborators

  • arondn2