Skip to content

Simple node module to deal with translation in your app

License

Notifications You must be signed in to change notification settings

luxferoo/itranslator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

translator

node module to deal with translation in your app

Install

Using yarn :

yarn add itranslator

Using npm :

npm install itranslator

Usage

const {
  trans,
  setConfig
} = require('itranslator');

//Returns the same string if no configuration provided
trans('en.hello'); // "en.hello" 

//You can put a global configuration at the entry point of your app
setConfig({
  source : {
    en : {
      hello : "hello"
    },
    it : { 
      hello : "bonjourno"
    }
  }
});

trans('en.hello'); // "hello" 
trans('it.hello'); // "bonjourno" 

//It's also possible to override the global configuration if needed
trans('it.hello',{
  vars : new Map().set('name', 'imam'),
  source : {
    it : {
      hello : 'bonjourno %name%'
    }
  }
}); // "bonjourno imam" 

trans('it.hello'); // "bonjourno imam" 

About

Simple node module to deal with translation in your app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages