vnti18n
v1.0.7
Published
Multi language lib
Downloads
72
Readme
USAGE
npm install vnti18n
- Define language
Each language, you need to create a js file that contain an object. Sample:
let vi = {
'hello %s': 'xin chao %s'
}
module.exports = vi
let en = {
'hello %s': 'Hello %s'
}
module.exports = en
- Configure
let i18n = require('vnti18n')
//config
i18n.locales.vi = require('./data/vi')
i18n.locales.en = require('./data/en')
//If you need you file can reloadable, using addLanguage instead
i18n.addLanguage('en', __dirname+'/data/en');
i18n.addLanguage('vi', __dirname+'/data/vi');
//When you need reload data, just call
i18n.reloadData();
... and more
- Usage
console.log(i18n.get('en', 'hello %s', 'cong'))
//or
console.log('hello %s'.localize('vi', 'cong'))