vnti18n

1.0.7 • Public • Published

USAGE

npm install vnti18n
  1. 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
  1. 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
  1. Usage
console.log(i18n.get('en', 'hello %s', 'cong'))
//or
console.log('hello %s'.localize('vi', 'cong'))

Readme

Keywords

Package Sidebar

Install

npm i vnti18n

Weekly Downloads

9

Version

1.0.7

License

ISC

Last publish

Collaborators

  • congntdev