basic-multilang
Basic implemetation of multilang support for NodeJS.
Installation
npm install basic-multilang --save
Usage
Include
var I18n = ;
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 1var i18n = path;// Option 2var reload = require;var i18n = path 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;
i81n.getLang()
;
Return then language to seted.
const lang = i18n;
i81n.get(key)
;
Return the translation for a specific key.
Arguments
Name | Type | Description |
---|---|---|
key |
string |
Key to get translation. |
var i18n = path;i18n;const translation = i18n;// 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