0.0.5 • Published 4 years ago

basic-multilang v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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
NameTypeDescription
directorystringTranslations directory.
reloadfunctionFuncion 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
NameTypeDescription
langstringLanguage 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
NameTypeDescription
keystringKey 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

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago