Minimalistic internationalization using gettext style for NodeJS
MIT License
Minimalistic internationalization using gettext style for NodeJS
Module available through the npm registry. It can be installed using the npm
or yarn
command line tool.
# Yarn (Recomend)
yarn global add nodejs-i18n
# NPM
npm install nodejs-i18n --global
# Create file
find . | grep .js | sort | nodejs-i18n > en.po
# Create file (all strings) [beta]
find . | grep .js | sort | nodejs-i18n --all > en.po
# Create file (get identifier value) [beta]
find . | grep .js | sort | nodejs-i18n --value > en.po
const { Resources, Translation } = require('nodejs-i18n')
const resources = new Resources()
resources.load('pt', 'pt.po')
const user = new Translation('pt')
//i18n: My Hello World with NodeJs i18n
const world = user._`world` // Mundo
user._`Hello ${world}` // Olá mundo
Lang id. Default value:
en
Load translation
Lang id.
File path
Remove translation.
Lang id.
Select translation.
Lang id.
String translation.
Create en.po files with nodejs-i18n
. Add in your package.json
"scripts": {
"i18n": "find . | grep .js | sort | nodejs-i18n > en.po"
}
and run $ npm run i18n
or $ yarn i18n
To run the test suite, first install the dependencies, then run test
:
# Using Yarn
yarn test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. List of all contributors.