simple-translate
v1.0.0
Published
Really simple and dumb possibility to use a translate helper in your project.
Downloads
5
Readme
Dead Simple translations
This module provides you an easy way to translate strings. Just pass in an object to .create with all your locales + translations and you will get a function to translate strings.
Installation
npm install simple-translate
Usage
var Translate = require("this-translate-module");
var translations = {
"en": {
"hello": "Hello!",
"hello_name": "Hello {{name}}!"
},
"de": {
"hello": "Hallo!",
"hello_name": "Hallo {{name}}!"
}
}
# default locale is "en"
var translate = Translate.create(translations);
translate("hello"); // "Hello!"
translate("hello_name", {name: "Horst"}); // "Hello Horst!"
# If you want any other locale you can simply set the "locale" property
translations.locale = "de";
var translate = Translate.create(translations);
translate("hello"); // "Hello!"
translate("hello_name", {name: "Horst"}); // "Hello Horst!"