1.0.1 • Published 5 years ago

npm-i18n-helper v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

npm-i18n-helper

The lib goal is to provide an easier i18n resource handling.

It is inspired by @ngx-translate/core structure. But it can be used in any project with the same structure.

This lib requires the following folder structure:

PROJECT_ROOT
│
└───src
│   │
│   └───assets
│       │  
│       └───i18n
│       │   │   en.json
│       │   |   pt.json
│       │   |   ...

Install

Locally on your project:

npm install npm-i18n-helper --save-dev

Global install:

npm install -g npm-i18n-helper

Test

npm test

Usage

npm-i18n-helper add [key] [languageKey]="[String]"

Example:

npm-i18n-helper add HELLO en="Hello World!"

It will produce the following entry in the 'en.json' (if the file doesn't exist it will be created) file:

{
  "HELLO": "Hello World!"
}

You can add multiple languages at once:

npm-i18n-helper add HELLO en="Hello World!" pt="Olá mundo!"

It supports nesting keys:

npm-i18n-helper add HELLO.WORLD en="Hello World!" pt="Olá mundo!"    

it will produce:

{
  "HELLO": {
      "WORLD": "Hello World!"
  }
}