Comparing version 2.1.5 to 2.1.6
{ | ||
"name": "i18njs", | ||
"main": "i18njs.js", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"homepage": "https://github.com/yoannmoinet/i18njs", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -1,3 +0,3 @@ | ||
<a name="2.1.5"></a> | ||
## [2.1.5](https://github.com/yoannmoinet/i18njs/compare/v2.1.5...v2.1.5) (2015-10-13) | ||
<a name="2.1.6"></a> | ||
## [2.1.6](https://github.com/yoannmoinet/i18njs/compare/v2.1.6...v2.1.6) (2015-10-13) | ||
@@ -7,8 +7,12 @@ | ||
<a name="2.1.5"></a> | ||
## [2.1.5](https://github.com/yoannmoinet/i18njs/compare/v2.1.4...v2.1.5) (2015-10-13) | ||
<a name="2.1.6"></a> | ||
## [2.1.6](https://github.com/yoannmoinet/i18njs/compare/v2.1.4...v2.1.6) (2015-10-13) | ||
### Bug Fixes | ||
* **get:** only return a template if needed ([ca07b69](https://github.com/yoannmoinet/i18njs/commit/ca07b69)) | ||
<a name="2.1.4"></a> | ||
@@ -151,6 +155,6 @@ ## [2.1.4](https://github.com/yoannmoinet/i18njs/compare/v2.1.3...v2.1.4) (2015-10-07) | ||
* add Travis CI ([988fc16](https://github.com/yoannmoinet/i18njs/commit/988fc16)) | ||
* add changelog ([45a3ccd](https://github.com/yoannmoinet/i18njs/commit/45a3ccd)) | ||
* add defaults template values ([3601034](https://github.com/yoannmoinet/i18njs/commit/3601034)) | ||
* add linting ([b9de51a](https://github.com/yoannmoinet/i18njs/commit/b9de51a)) | ||
* add Travis CI ([988fc16](https://github.com/yoannmoinet/i18njs/commit/988fc16)) | ||
* **npm:** add scripts ([4b6b378](https://github.com/yoannmoinet/i18njs/commit/4b6b378)) | ||
@@ -157,0 +161,0 @@ |
@@ -155,8 +155,17 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.i18njs = f()}})(function(){var define,module,exports; | ||
defaults || {}; | ||
var needsTemplate = false; | ||
if (typeof st !== 'function' && typeof template === 'function') { | ||
for (i in settings) { | ||
if (settings.hasOwnProperty(i) && settings[i].test(st)) { | ||
needsTemplate = true; | ||
break; | ||
} | ||
} | ||
if (needsTemplate && typeof st !== 'function' && | ||
typeof template === 'function') { | ||
st = template(st, settings); | ||
} | ||
return st(newDatas); | ||
return typeof st === 'function' ? st(newDatas) : st; | ||
}; | ||
@@ -163,0 +172,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.i18njs=t()}}(function(){var t=/(.)^/,n=/\\|'|\r|\n|\u2028|\u2029/g,e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},i=function(t){"use strict";var n=function(n){return t[n]},e="(?:"+Object.keys(t).join("|")+")",r=RegExp(e),i=RegExp(e,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,n):t}},o=function(t){"use strict";return"\\"+r[t]},u=function(r,u){"use strict";var s=0,a="__p+='",c=RegExp([(u.escape||t).source,(u.interpolate||t).source,(u.evaluate||t).source].join("|")+"|$","g");r.replace(c,function(t,e,i,u,c){return a+=r.slice(s,c).replace(n,o),s=c+t.length,e?a+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":i?a+="'+\n((__t=("+i+"))==null?'':__t)+\n'":u&&(a+="';\n"+u+"\n__p+='"),t}),a+="';\n",a="with(obj||{}){\n"+a+"}\n",a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var f=new Function("obj","_",a)}catch(p){throw p.source=a,p}var l=function(t){return f.call(this,t,{escape:i(e)})};return l.source="function (data) {\n return "+f.toString()+".call(this, data, {\n escape:"+i.toString()+".call(this, { '&': '&', '<': '<', '>': '>','\"': '"', \"'\": ''','`': '`'})})}",l},s=function(t,n){"use strict";for(var e=t.split(".");n&&e.length;)n=n[e.shift()];return n},a=function(t,n){"use strict";for(var e in n)if(t.hasOwnProperty(e)){var r=typeof t[e],i=typeof n[e];r===i?"object"!==r?t[e]=n[e]:a(t[e],n[e]):t[e]=n[e]}else n.hasOwnProperty(e)&&(t[e]=n[e]);return t},c=function(t,n,e,r,i){"use strict";var o=/\{\{([\s\S]+?)\}\}/g,s=/\{\{=([\s\S]+?)\}\}/g,c=/\{\{-([\s\S]+?)\}\}/g;e=e||{};var f={evaluate:e.evaluate||o,interpolate:e.interpolate||s,escape:e.escape||c},p=a(a(i,i[r]),n)||i||{};return"function"!=typeof t&&"function"==typeof u&&(t=u(t,f)),t(p)},f=function(){"use strict";var t="en",n={},e={};this.add=function(t,e,r){var i;n[t]=n[t]||{},void 0===r?(r=e,e=void 0,i=n[t]):(n[t][e]=n[t][e]||{},i=n[t][e]),i=a(i,r)},this.has=function(e,r){r=r||t;var i=r+"."+e;return n[e]?!0:s(i,n)?!0:!1},this.listLangs=function(){var t=[];for(var e in n)t.push(e);return t},this.getCurrentLang=function(){return t},this.getDico=function(){return n},this.getDefaults=function(){return e},this.setLang=function(n){return t=n},this.setDefaults=function(t){e=a(e,t||{})},this.get=function(r,i,o,u){var a=u||t;void 0===u&&("string"==typeof i?(a=i,i=void 0):"string"==typeof o&&(a=o));var f=s(a+"."+r,n)||s(a+"."+r,e)||s(r,e);o=o||{};var p=r;return"string"==typeof f||"function"==typeof f?p=c(f,i,o,a,e):"object"==typeof f&&(p=f),p}};return new f}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.i18njs=t()}}(function(){var t=/(.)^/,n=/\\|'|\r|\n|\u2028|\u2029/g,e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},i=function(t){"use strict";var n=function(n){return t[n]},e="(?:"+Object.keys(t).join("|")+")",r=RegExp(e),i=RegExp(e,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,n):t}},o=function(t){"use strict";return"\\"+r[t]},u=function(r,u){"use strict";var s=0,a="__p+='",f=RegExp([(u.escape||t).source,(u.interpolate||t).source,(u.evaluate||t).source].join("|")+"|$","g");r.replace(f,function(t,e,i,u,f){return a+=r.slice(s,f).replace(n,o),s=f+t.length,e?a+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":i?a+="'+\n((__t=("+i+"))==null?'':__t)+\n'":u&&(a+="';\n"+u+"\n__p+='"),t}),a+="';\n",a="with(obj||{}){\n"+a+"}\n",a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var c=new Function("obj","_",a)}catch(p){throw p.source=a,p}var l=function(t){return c.call(this,t,{escape:i(e)})};return l.source="function (data) {\n return "+c.toString()+".call(this, data, {\n escape:"+i.toString()+".call(this, { '&': '&', '<': '<', '>': '>','\"': '"', \"'\": ''','`': '`'})})}",l},s=function(t,n){"use strict";for(var e=t.split(".");n&&e.length;)n=n[e.shift()];return n},a=function(t,n){"use strict";for(var e in n)if(t.hasOwnProperty(e)){var r=typeof t[e],i=typeof n[e];r===i?"object"!==r?t[e]=n[e]:a(t[e],n[e]):t[e]=n[e]}else n.hasOwnProperty(e)&&(t[e]=n[e]);return t},f=function(t,n,e,r,i){"use strict";var o,s=/\{\{([\s\S]+?)\}\}/g,f=/\{\{=([\s\S]+?)\}\}/g,c=/\{\{-([\s\S]+?)\}\}/g;e=e||{};var p={evaluate:e.evaluate||s,interpolate:e.interpolate||f,escape:e.escape||c},l=a(a(i,i[r]),n)||i||{},g=!1;for(o in p)if(p.hasOwnProperty(o)&&p[o].test(t)){g=!0;break}return g&&"function"!=typeof t&&"function"==typeof u&&(t=u(t,p)),"function"==typeof t?t(l):t},c=function(){"use strict";var t="en",n={},e={};this.add=function(t,e,r){var i;n[t]=n[t]||{},void 0===r?(r=e,e=void 0,i=n[t]):(n[t][e]=n[t][e]||{},i=n[t][e]),i=a(i,r)},this.has=function(e,r){r=r||t;var i=r+"."+e;return n[e]?!0:s(i,n)?!0:!1},this.listLangs=function(){var t=[];for(var e in n)t.push(e);return t},this.getCurrentLang=function(){return t},this.getDico=function(){return n},this.getDefaults=function(){return e},this.setLang=function(n){return t=n},this.setDefaults=function(t){e=a(e,t||{})},this.get=function(r,i,o,u){var a=u||t;void 0===u&&("string"==typeof i?(a=i,i=void 0):"string"==typeof o&&(a=o));var c=s(a+"."+r,n)||s(a+"."+r,e)||s(r,e);o=o||{};var p=r;return"string"==typeof c||"function"==typeof c?p=f(c,i,o,a,e):"object"==typeof c&&(p=c),p}};return new c}); |
{ | ||
"name": "i18njs", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "Simplistic I18N tool for universal/isomorphic Javascript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/i18njs.js", |
@@ -28,3 +28,6 @@ ![logo](./dist/logo.png) | ||
function () { | ||
return i18njs.get.apply(i18njs, arguments); | ||
// Pass all arguments except the last one | ||
// that is a Handlebars specific. | ||
return i18njs.get.apply(i18njs, | ||
Array.prototype.slice.call(arguments, 0, -1)); | ||
} | ||
@@ -31,0 +34,0 @@ ); |
@@ -49,8 +49,17 @@ /*globals template*/ | ||
defaults || {}; | ||
var needsTemplate = false; | ||
if (typeof st !== 'function' && typeof template === 'function') { | ||
for (i in settings) { | ||
if (settings.hasOwnProperty(i) && settings[i].test(st)) { | ||
needsTemplate = true; | ||
break; | ||
} | ||
} | ||
if (needsTemplate && typeof st !== 'function' && | ||
typeof template === 'function') { | ||
st = template(st, settings); | ||
} | ||
return st(newDatas); | ||
return typeof st === 'function' ? st(newDatas) : st; | ||
}; | ||
@@ -57,0 +66,0 @@ |
822
293
56223
28