Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "i18njs", | ||
"main": "i18njs.js", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/yoannmoinet/i18njs", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -126,4 +126,12 @@ if (typeof exports === 'object' && typeof define !== 'function') { | ||
}; | ||
this.get = function (key, data, options) { | ||
var obj = parse(this.lng + '.' + key, this.string); | ||
this.get = function (key, data, options, lang) { | ||
var lng = lang || this.lng; | ||
if (lang === undefined) { | ||
if (typeof data === 'string') { | ||
lng = data; | ||
} else if (typeof options === 'string') { | ||
lng = options; | ||
} | ||
} | ||
var obj = parse(lng + '.' + key, this.string); | ||
options = options || {}; | ||
@@ -130,0 +138,0 @@ if (obj && typeof data === 'object') { |
{ | ||
"name": "i18njs", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "A simple i18n for Javascript with a templating feature.", | ||
@@ -5,0 +5,0 @@ "main": "i18njs.js", |
@@ -41,4 +41,12 @@ # i18njs | ||
var fr_locales = { | ||
'hello_world': { | ||
'hello': 'Bonjour', | ||
'world': 'Monde' | ||
} | ||
}; | ||
// i18n.add(language, [namespace,] locales); | ||
i18n.add('en', 'first_test', en_locales); | ||
i18n.add('fr', 'first_test', fr_locales); | ||
@@ -75,6 +83,9 @@ ``` | ||
// i18n.get(key[, data, options]); | ||
// i18n.get(key[, data, options][, lang]); | ||
i18n.get('first_test.hello_world.hello'); | ||
// Hello | ||
i18n.get('first_test.hello_world.hello', 'fr'); | ||
// Bonjour | ||
``` | ||
@@ -81,0 +92,0 @@ |
176
129
9886
5