Package Exports
- tiny-i18n-node
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tiny-i18n-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
tiny-translation-node
The simplest NodeJS i18n module
Install
$ npm install tiny-i18n-node
Usage
First of all, create your lang/*.json
files inside your root folder.
See some examples
en.json
{
"module": {
"description": "The simplest NodeJS i18n module"
},
"users": {
"welcome": "Welcome, :name!"
}
}
es.json
{
"module": {
"description": "El módulo de internacionalización NodeJS más sencillo"
},
"users": {
"welcome": "¡Bienvenido, :name!"
}
}
br.json
{
"module": {
"description": "O mais simples módulo de internacionalização utilizando NodeJS"
},
"users": {
"welcome": "Bem-vindo, :name!"
}
}
Then use it:
const trans = require('tiny-i18n-node')
trans('module.description') //=> "Tiny module to handle NodeJS i18n"
You get the current location:
trans.getLocale() //=> Default: "en"
Or switch between them:
// Switch to Spanish
trans.setLocale('es')
trans('module.description') //=> "Pequeño módulo para manejar la internacionalización de Node JS"
Set some replacements:
trans('users.welcome', {name: 'John'}) //=> "Welcome, John!"
License
MIT © Alison Monteiro