frenchkiss
Advanced tools
Comparing version 0.1.0 to 0.2.0
/** | ||
* @license frenchkiss 0.1.0 | ||
* @license frenchkiss 0.2.0 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
"use strict";var t=/^\s*\w+\s*$/,e=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,r=function(t){return'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))'};function u(t){for(var e={},u=function t(e,u){var o=[];var f=e.length;for(var i=0;i<f;++i){var s=e[i],l=s[0],a=s[1],c="";if(0===l&&a)c=n(a);else if(1===l)c=r(a.trim());else if(2===l){for(var p=s[2],v=s[3],h=s[4],g=v.length,y=0;y<g;++y)h?"="===v[y][0][0]?c+='p["'+p+'"]=='+n(v[y][0].substr(1)):(u[p]=1,c+='m["'+p+'"]=='+n(v[y][0])):c+='p["'+p+'"]=='+n(v[y][0]),c+="?"+t(v[y][1],u)+":";c="("+c+t(a,u)+")"}c&&o.push(c)}return o.join("+")||'""'}(o(t),e),f=Object.keys(e),i=f.length,s=[],l=0;l<i;++l)s[l]=f[l]+':f(p["'+f[l]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(i?",m=f?{"+s+"}:{}":"")+";return "+u)}function o(n){for(var r=0,u="",o=n.length,i=[],s=0;s<o;++s){var l=n[s],a=void 0;"{"===l?r++||(a=[0,u]):"}"===l&&(--r||(a=t.test(u)?[1,u]:e.test(u)?f(u):[0,u])),a?(i.push(a),u=""):u+=l}return i.push([0,u]),i}function f(t){for(var n=t.match(e),r=n[1],u="p"===n[2][0].toLowerCase(),f=o(t.replace(e,"")),i=f.length,s=[],l=[0,""],a=0;a<i-1;){var c=f[a++][1].trim(),p=o(f[a++][1]);"other"===c?l=p:u&&"="===c[0]?s.unshift([c,p]):s.push([c,p])}return[2,l,r,s,u]}var i={},s={},l={},a="",c="",p=function(t){return t},v=function(){return""},h=function(t,e){return i[e]&&i[e][t]||g(t,e)},g=function(t,e){var n=s[e];if(n){if("string"==typeof n[t])n=n[t];else for(var r=t.split("."),o=r.length,f=0;f<o;++f){if(!n.hasOwnProperty(r[f]))return null;n=n[r[f]]}if("string"==typeof n)return i[e][t]=u(n)}return null},y=function t(e,n,r,u){for(var o=Object.keys(n),f=o.length,i=0;i<f;++i){var s=o[i],l=u?u+"."+s:s;if("object"==typeof n[s])"object"!=typeof e[s]&&(e[s]={}),t(e[s],n[s],r,l);else{if(delete r[l],"object"==typeof e[s])for(var a=l+".",c=a.length,p=Object.keys(r),v=p.length,h=0;h<v;++h){var g=p[h];g.substr(0,c)===a&&delete r[g]}e[s]=n[s]}}},b={cache:i,store:s,t:function(t,e,n){var r,u=n||a;return u&&(r=h(t,u))?r(e,l[u],t,u,v):(u=c)&&(r=h(t,u))?r(e,l[u],t,u,v):p(t)},onMissingKey:function(t){p=t},onMissingVariable:function(t){v=t},locale:function(t){return t&&(a=t),a},fallback:function(t){return t&&(c=t),c},set:function(t,e){i[t]={},s[t]=e},unset:function(t){delete i[t],delete s[t]},extend:function(t,e){s[t]||(s[t]={}),i[t]||(i[t]={}),y(s[t],e,i[t],"")},plural:function(t,e){l[t]=e}};module.exports=b; | ||
"use strict";var t=/^\s*\w+\s*$/,n=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,e=JSON.stringify,r=function(t){return'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))'};function o(t){for(var n={},o=function t(n,o){var u=[];var i=n.length;for(var f=0;f<i;++f){var s=n[f],c=s[0],a=s[1],l="";if(0===c&&a)l=e(a);else if(1===c)l=r(a.trim());else if(2===c){for(var v=s[2],p=s[3],h=s[4],g=p.length,b=0;b<g;++b)h?"="===p[b][0][0]?l+='p["'+v+'"]=='+e(p[b][0].substr(1)):(o[v]=1,l+='m["'+v+'"]=='+e(p[b][0])):l+='p["'+v+'"]=='+e(p[b][0]),l+="?"+t(p[b][1],o)+":";l="("+l+t(a,o)+")"}l&&u.push(l)}return u.join("+")||'""'}(u(t),n),i=Object.keys(n),f=i.length,s=[],c=0;c<f;++c)s[c]=i[c]+':f(p["'+i[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(f?",m=f?{"+s+"}:{}":"")+";return "+o)}function u(e){for(var r=0,o="",u=e.length,f=[],s=0;s<u;++s){var c=e[s],a=void 0;"{"===c?r++||(a=[0,o]):"}"===c&&(--r||(a=t.test(o)?[1,o]:n.test(o)?i(o):[0,o])),a?(f.push(a),o=""):o+=c}return f.push([0,o]),f}function i(t){for(var e=t.match(n),r=e[1],o="p"===e[2][0].toLowerCase(),i=u(t.replace(n,"")),f=i.length,s=[],c=[0,""],a=0;a<f-1;){var l=i[a++][1].trim(),v=u(i[a++][1]);"other"===l?c=v:o&&"="===l[0]?s.unshift([l,v]):s.push([l,v])}return[2,c,r,s,o]}var f={},s={},c={},a="",l="",v=function(t){return t},p=function(){return""},h=function(t,n){return f[n]&&f[n][t]||s[n]&&"string"==typeof s[n][t]&&(f[n][t]=o(s[n][t]))},g=function t(n,e,r){for(var o=Object.keys(e),u=o.length,i=0;i<u;++i){var f=o[i],s=r+f;"object"==typeof e[f]?(t(n,e[f],s+"."),delete n[f]):n[s]=e[f]+""}},b=function t(n,e,r,o){for(var u=Object.keys(r),i=u.length,f=0;f<i;++f){var s=u[f],c=o+s;"object"==typeof r[s]?t(n,e,r[s],c+"."):n[c]!==r[s]&&(delete e[c],n[c]=r[s]+"")}},y={cache:f,store:s,t:function(t,n,e){var r,o=e||a;return o&&(r=h(t,o))?r(n,c[o],t,o,p):(o=l)&&(r=h(t,o))?r(n,c[o],t,o,p):v(t,n,e||a)},onMissingKey:function(t){v=t},onMissingVariable:function(t){p=t},locale:function(t){return t&&(a=t),a},fallback:function(t){return t&&(l=t),l},set:function(t,n){g(n,n,""),f[t]={},s[t]=n},unset:function(t){delete f[t],delete s[t]},extend:function(t,n){s[t]||(s[t]={}),f[t]||(f[t]={}),b(s[t],f[t],n,"")},plural:function(t,n){c[t]=n}};module.exports=y; |
/** | ||
* @license frenchkiss 0.1.0 | ||
* @license frenchkiss 0.2.0 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
const t=/^\s*\w+\s*$/,e=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,s=t=>'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))';function l(t){const e={},l=function t(e,l){const o=[];const r=e.length;for(let c=0;c<r;++c){const r=e[c],f=r[0],i=r[1];let u="";if(0===f&&i)u=n(i);else if(1===f)u=s(i.trim());else if(2===f){const e=r[2],s=r[3],o=r[4],c=s.length;for(let r=0;r<c;++r)o?"="===s[r][0][0]?u+='p["'+e+'"]=='+n(s[r][0].substr(1)):(l[e]=1,u+='m["'+e+'"]=='+n(s[r][0])):u+='p["'+e+'"]=='+n(s[r][0]),u+="?"+t(s[r][1],l)+":";u="("+u+t(i,l)+")"}u&&o.push(u)}return o.join("+")||'""'}(o(t),e),r=Object.keys(e),c=r.length,f=[];for(let t=0;t<c;++t)f[t]=r[t]+':f(p["'+r[t]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(c?",m=f?{"+f+"}:{}":"")+";return "+l)}function o(n){let s=0,l="";const o=n.length,c=[];for(let f=0;f<o;++f){const o=n[f];let i;"{"===o?s++||(i=[0,l]):"}"===o&&(--s||(i=t.test(l)?[1,l]:e.test(l)?r(l):[0,l])),i?(c.push(i),l=""):l+=o}return c.push([0,l]),c}function r(t){const n=t.match(e),s=n[1],l="p"===n[2][0].toLowerCase(),r=o(t.replace(e,"")),c=r.length,f=[];let i=[0,""];for(let t=0;t<c-1;){let e=r[t++][1].trim();const n=o(r[t++][1]);"other"===e?i=n:l&&"="===e[0]?f.unshift([e,n]):f.push([e,n])}return[2,i,s,f,l]}const c={},f={};let i={},u="",p="",h=t=>t,a=()=>"";const g=(t,e)=>c[e]&&c[e][t]||y(t,e),y=(t,e)=>{let n=f[e];if(n){if("string"==typeof n[t])n=n[t];else{const e=t.split("."),s=e.length;for(let t=0;t<s;++t){if(!n.hasOwnProperty(e[t]))return null;n=n[e[t]]}}if("string"==typeof n)return c[e][t]=l(n)}return null},b=(t,e,n)=>{let s,l=n||u;return l&&(s=g(t,l))?s(e,i[l],t,l,a):(l=p)&&(s=g(t,l))?s(e,i[l],t,l,a):h(t)},j=t=>{h=t},d=t=>{a=t},k=t=>(t&&(u=t),u),m=t=>(t&&(p=t),p),O=(t,e)=>{c[t]={},f[t]=e},w=(t,e)=>{i[t]=e},v=(t,e)=>{f[t]||(f[t]={}),c[t]||(c[t]={}),x(f[t],e,c[t],"")},x=(t,e,n,s)=>{const l=Object.keys(e),o=l.length;for(let r=0;r<o;++r){const o=l[r],c=s?s+"."+o:o;if("object"==typeof e[o])"object"!=typeof t[o]&&(t[o]={}),x(t[o],e[o],n,c);else{if(delete n[c],"object"==typeof t[o]){const t=c+".",e=t.length,s=Object.keys(n),l=s.length;for(let o=0;o<l;++o){const l=s[o];l.substr(0,e)===t&&delete n[l]}}t[o]=e[o]}}},M=t=>{delete c[t],delete f[t]};export default{cache:c,store:f,t:b,onMissingKey:j,onMissingVariable:d,locale:k,fallback:m,set:O,unset:M,extend:v,plural:w};export{c as cache,f as store,b as t,j as onMissingKey,d as onMissingVariable,k as locale,m as fallback,O as set,w as plural,v as extend,M as unset}; | ||
const t=/^\s*\w+\s*$/,e=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,s=t=>'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))';function o(t){const e={},o=function t(e,o){const l=[];const r=e.length;for(let c=0;c<r;++c){const r=e[c],f=r[0],i=r[1];let u="";if(0===f&&i)u=n(i);else if(1===f)u=s(i.trim());else if(2===f){const e=r[2],s=r[3],l=r[4],c=s.length;for(let r=0;r<c;++r)l?"="===s[r][0][0]?u+='p["'+e+'"]=='+n(s[r][0].substr(1)):(o[e]=1,u+='m["'+e+'"]=='+n(s[r][0])):u+='p["'+e+'"]=='+n(s[r][0]),u+="?"+t(s[r][1],o)+":";u="("+u+t(i,o)+")"}u&&l.push(u)}return l.join("+")||'""'}(l(t),e),r=Object.keys(e),c=r.length,f=[];for(let t=0;t<c;++t)f[t]=r[t]+':f(p["'+r[t]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(c?",m=f?{"+f+"}:{}":"")+";return "+o)}function l(n){let s=0,o="";const l=n.length,c=[];for(let f=0;f<l;++f){const l=n[f];let i;"{"===l?s++||(i=[0,o]):"}"===l&&(--s||(i=t.test(o)?[1,o]:e.test(o)?r(o):[0,o])),i?(c.push(i),o=""):o+=l}return c.push([0,o]),c}function r(t){const n=t.match(e),s=n[1],o="p"===n[2][0].toLowerCase(),r=l(t.replace(e,"")),c=r.length,f=[];let i=[0,""];for(let t=0;t<c-1;){let e=r[t++][1].trim();const n=l(r[t++][1]);"other"===e?i=n:o&&"="===e[0]?f.unshift([e,n]):f.push([e,n])}return[2,i,s,f,o]}const c={},f={};let i={},u="",p="",a=t=>t,h=()=>"";const g=(t,e)=>c[e]&&c[e][t]||f[e]&&"string"==typeof f[e][t]&&(c[e][t]=o(f[e][t])),b=(t,e,n)=>{let s,o=n||u;return o&&(s=g(t,o))?s(e,i[o],t,o,h):(o=p)&&(s=g(t,o))?s(e,i[o],t,o,h):a(t,e,n||u)},y=t=>{a=t},d=t=>{h=t},j=t=>(t&&(u=t),u),k=t=>(t&&(p=t),p),m=(t,e)=>{O(e,e,""),c[t]={},f[t]=e},O=(t,e,n)=>{const s=Object.keys(e),o=s.length;for(let l=0;l<o;++l){const o=s[l],r=n+o;"object"==typeof e[o]?(O(t,e[o],r+"."),delete t[o]):t[r]=e[o]+""}},v=(t,e)=>{i[t]=e},w=(t,e)=>{f[t]||(f[t]={}),c[t]||(c[t]={}),x(f[t],c[t],e,"")},x=(t,e,n,s)=>{const o=Object.keys(n),l=o.length;for(let r=0;r<l;++r){const l=o[r],c=s+l;"object"==typeof n[l]?x(t,e,n[l],c+"."):t[c]!==n[l]&&(delete e[c],t[c]=n[l]+"")}},M=t=>{delete c[t],delete f[t]};export default{cache:c,store:f,t:b,onMissingKey:y,onMissingVariable:d,locale:j,fallback:k,set:m,unset:M,extend:w,plural:v};export{c as cache,f as store,b as t,y as onMissingKey,d as onMissingVariable,j as locale,k as fallback,m as set,v as plural,w as extend,M as unset}; |
/** | ||
* @license frenchkiss 0.1.0 | ||
* @license frenchkiss 0.2.0 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
var e,t;e=this,t=function(){"use strict";var e=/^\s*\w+\s*$/,t=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,r=function(e){return'(p["'+e+'"]||(p["'+e+'"]=="0"?0:"'+e+'" in p?"":v("'+e+'",k,l)))'};function f(e){for(var t={},f=function e(t,f){var o=[];var i=t.length;for(var u=0;u<i;++u){var s=t[u],c=s[0],l=s[1],a="";if(0===c&&l)a=n(l);else if(1===c)a=r(l.trim());else if(2===c){for(var p=s[2],v=s[3],h=s[4],d=v.length,g=0;g<d;++g)h?"="===v[g][0][0]?a+='p["'+p+'"]=='+n(v[g][0].substr(1)):(f[p]=1,a+='m["'+p+'"]=='+n(v[g][0])):a+='p["'+p+'"]=='+n(v[g][0]),a+="?"+e(v[g][1],f)+":";a="("+a+e(l,f)+")"}a&&o.push(a)}return o.join("+")||'""'}(o(e),t),i=Object.keys(t),u=i.length,s=[],c=0;c<u;++c)s[c]=i[c]+':f(p["'+i[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(u?",m=f?{"+s+"}:{}":"")+";return "+f)}function o(n){for(var r=0,f="",o=n.length,u=[],s=0;s<o;++s){var c=n[s],l=void 0;"{"===c?r++||(l=[0,f]):"}"===c&&(--r||(l=e.test(f)?[1,f]:t.test(f)?i(f):[0,f])),l?(u.push(l),f=""):f+=c}return u.push([0,f]),u}function i(e){for(var n=e.match(t),r=n[1],f="p"===n[2][0].toLowerCase(),i=o(e.replace(t,"")),u=i.length,s=[],c=[0,""],l=0;l<u-1;){var a=i[l++][1].trim(),p=o(i[l++][1]);"other"===a?c=p:f&&"="===a[0]?s.unshift([a,p]):s.push([a,p])}return[2,c,r,s,f]}var u={},s={},c={},l="",a="",p=function(e){return e},v=function(){return""},h=function(e,t){return u[t]&&u[t][e]||d(e,t)},d=function(e,t){var n=s[t];if(n){if("string"==typeof n[e])n=n[e];else for(var r=e.split("."),o=r.length,i=0;i<o;++i){if(!n.hasOwnProperty(r[i]))return null;n=n[r[i]]}if("string"==typeof n)return u[t][e]=f(n)}return null},g=function e(t,n,r,f){for(var o=Object.keys(n),i=o.length,u=0;u<i;++u){var s=o[u],c=f?f+"."+s:s;if("object"==typeof n[s])"object"!=typeof t[s]&&(t[s]={}),e(t[s],n[s],r,c);else{if(delete r[c],"object"==typeof t[s])for(var l=c+".",a=l.length,p=Object.keys(r),v=p.length,h=0;h<v;++h){var d=p[h];d.substr(0,a)===l&&delete r[d]}t[s]=n[s]}}};return{cache:u,store:s,t:function(e,t,n){var r,f=n||l;return f&&(r=h(e,f))?r(t,c[f],e,f,v):(f=a)&&(r=h(e,f))?r(t,c[f],e,f,v):p(e)},onMissingKey:function(e){p=e},onMissingVariable:function(e){v=e},locale:function(e){return e&&(l=e),l},fallback:function(e){return e&&(a=e),a},set:function(e,t){u[e]={},s[e]=t},unset:function(e){delete u[e],delete s[e]},extend:function(e,t){s[e]||(s[e]={}),u[e]||(u[e]={}),g(s[e],t,u[e],"")},plural:function(e,t){c[e]=t}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).frenchkiss=t(); | ||
var e,t;e=this,t=function(){"use strict";var e=/^\s*\w+\s*$/,t=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,r=function(e){return'(p["'+e+'"]||(p["'+e+'"]=="0"?0:"'+e+'" in p?"":v("'+e+'",k,l)))'};function o(e){for(var t={},o=function e(t,o){var f=[];var u=t.length;for(var i=0;i<u;++i){var s=t[i],c=s[0],a=s[1],l="";if(0===c&&a)l=n(a);else if(1===c)l=r(a.trim());else if(2===c){for(var p=s[2],v=s[3],h=s[4],d=v.length,g=0;g<d;++g)h?"="===v[g][0][0]?l+='p["'+p+'"]=='+n(v[g][0].substr(1)):(o[p]=1,l+='m["'+p+'"]=='+n(v[g][0])):l+='p["'+p+'"]=='+n(v[g][0]),l+="?"+e(v[g][1],o)+":";l="("+l+e(a,o)+")"}l&&f.push(l)}return f.join("+")||'""'}(f(e),t),u=Object.keys(t),i=u.length,s=[],c=0;c<i;++c)s[c]=u[c]+':f(p["'+u[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(i?",m=f?{"+s+"}:{}":"")+";return "+o)}function f(n){for(var r=0,o="",f=n.length,i=[],s=0;s<f;++s){var c=n[s],a=void 0;"{"===c?r++||(a=[0,o]):"}"===c&&(--r||(a=e.test(o)?[1,o]:t.test(o)?u(o):[0,o])),a?(i.push(a),o=""):o+=c}return i.push([0,o]),i}function u(e){for(var n=e.match(t),r=n[1],o="p"===n[2][0].toLowerCase(),u=f(e.replace(t,"")),i=u.length,s=[],c=[0,""],a=0;a<i-1;){var l=u[a++][1].trim(),p=f(u[a++][1]);"other"===l?c=p:o&&"="===l[0]?s.unshift([l,p]):s.push([l,p])}return[2,c,r,s,o]}var i={},s={},c={},a="",l="",p=function(e){return e},v=function(){return""},h=function(e,t){return i[t]&&i[t][e]||s[t]&&"string"==typeof s[t][e]&&(i[t][e]=o(s[t][e]))},d=function e(t,n,r){for(var o=Object.keys(n),f=o.length,u=0;u<f;++u){var i=o[u],s=r+i;"object"==typeof n[i]?(e(t,n[i],s+"."),delete t[i]):t[s]=n[i]+""}},g=function e(t,n,r,o){for(var f=Object.keys(r),u=f.length,i=0;i<u;++i){var s=f[i],c=o+s;"object"==typeof r[s]?e(t,n,r[s],c+"."):t[c]!==r[s]&&(delete n[c],t[c]=r[s]+"")}};return{cache:i,store:s,t:function(e,t,n){var r,o=n||a;return o&&(r=h(e,o))?r(t,c[o],e,o,v):(o=l)&&(r=h(e,o))?r(t,c[o],e,o,v):p(e,t,n||a)},onMissingKey:function(e){p=e},onMissingVariable:function(e){v=e},locale:function(e){return e&&(a=e),a},fallback:function(e){return e&&(l=e),l},set:function(e,t){d(t,t,""),i[e]={},s[e]=t},unset:function(e){delete i[e],delete s[e]},extend:function(e,t){s[e]||(s[e]={}),i[e]||(i[e]={}),g(s[e],i[e],t,"")},plural:function(e,t){c[e]=t}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).frenchkiss=t(); |
@@ -10,2 +10,8 @@ declare module 'frenchkiss' { | ||
type missingKeyHandler = ( | ||
key: string, | ||
params: string, | ||
language: string | ||
) => string; | ||
interface StoreData { | ||
@@ -29,7 +35,11 @@ [key: string]: string | number | StoreData; | ||
interface StoreItems { | ||
[key: string]: string | number; | ||
} | ||
export const cache: CacheItems; | ||
export const store: StoreData; | ||
export const store: StoreItems; | ||
export function t(key: string, params?: object, language?: string): string; | ||
export function onMissingKey( | ||
missingKeyHandler: (key: string) => string | ||
missingKeyHandler: missingKeyHandler | ||
): void; | ||
@@ -36,0 +46,0 @@ export function onMissingVariable( |
{ | ||
"name": "frenchkiss", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "The blazing fast lightweight translation module for javascript", | ||
@@ -5,0 +5,0 @@ "author": "Vincent Thibault <vthibault.mobile@gmail.com>", |
@@ -5,3 +5,3 @@ <div align="center"> | ||
[![Build Status](https://travis-ci.com/koala-interactive/frenchkiss.js.svg?branch=master)](https://travis-ci.com/koala-interactive/frenchkiss.js) | ||
[![File size](https://img.shields.io/badge/GZIP%20size-1.2%20kB-brightgreen.svg)](./dist/umd/frenchkiss.js) | ||
[![File size](https://img.shields.io/badge/GZIP%20size-1.1%20kB-brightgreen.svg)](./dist/umd/frenchkiss.js) | ||
![](https://img.shields.io/badge/dependencies-none-brightgreen.svg) | ||
@@ -216,3 +216,3 @@ ![](https://img.shields.io/snyk/vulnerabilities/github/koala-interactive/frenchkiss.js.svg) | ||
frenchkiss.onMissingKey(key => { | ||
frenchkiss.onMissingKey((key, params, locale) => { | ||
// Send error to your server | ||
@@ -288,13 +288,19 @@ sendReport(`Missing the key "${key}" in ${frenchkiss.locale()} language.`); | ||
In case of duplicate names on key and objects, the result will always prioritize the key value. | ||
In case of duplicate names on key and objects, do not expect the result to be uniform (in fact, just don't do it). | ||
```js | ||
frenchkiss.set('en', { | ||
'fruits.apple': '(linear) apple' | ||
fruits: { | ||
apple: '(nested) apple' | ||
'fruits.apple.green': 1, | ||
'fruits.apple': { | ||
'green': 2 | ||
}, | ||
'fruits': { | ||
'apple.green': 3 | ||
'apple': { | ||
'green': 4 | ||
} | ||
} | ||
}); | ||
frenchkiss.t('fruits.apple'); // => '(linear) apple' | ||
frenchkiss.t('fruits.apple.green'); // => '1' or '2' or '3' or '4' | ||
``` | ||
@@ -301,0 +307,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89
428
24159