tml-js-browser
Advanced tools
Comparing version 0.4.55 to 0.4.56
@@ -263,3 +263,3 @@ /** | ||
sentences.forEach(function (sentence) { | ||
var sentenceTranslation = self.translateTmlFragment(sentence, data, label); | ||
var sentenceTranslation = self.translateTmlFragment(sentence, data, {label: label}); | ||
if (sentenceTranslation) | ||
@@ -272,3 +272,3 @@ translation = translation.replace(sentence, sentenceTranslation); | ||
return this.translateTmlFragment(tml, data, label); | ||
return this.translateTmlFragment(tml, data, {label: label, reset: true}); | ||
}, | ||
@@ -281,6 +281,8 @@ | ||
* @param data | ||
* @param label | ||
* @param opts | ||
* @returns {*} | ||
*/ | ||
translateTmlFragment: function(tml, data, label) { | ||
translateTmlFragment: function(tml, data, opts) { | ||
opts = opts || {}; | ||
tml = this.generateDataTokens(tml); | ||
@@ -290,8 +292,17 @@ data = data || this.tokens; | ||
// if (!this.isValidTml(tml)) return null; | ||
console.log(tml, data); | ||
// console.log(tml, data); | ||
var translation = tml; | ||
tml = tml.replace(/[\n]/g, '').replace(/\s\s+/g, ' ').trim(); | ||
translation = this.getOption("debug") ? this.debugTranslation(tml) : window[label ? "trl" : "tr"](tml, data, this.options); | ||
this.resetContext(); | ||
if (this.getOption("debug")) | ||
translation = this.debugTranslation(tml); | ||
else if (opts.label) | ||
translation = window.trl(tml, data, this.options); | ||
else | ||
translation = window.tr(tml, data, this.options); | ||
if (opts.reset) | ||
this.resetContext(); | ||
return translation; | ||
@@ -298,0 +309,0 @@ }, |
{ | ||
"name": "tml-js-browser", | ||
"description": "Translation plugin for browsers.", | ||
"version": "0.4.55", | ||
"version": "0.4.56", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Michael Berkovich", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
569943
12717