-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18nextMF2.min.js
1 lines (1 loc) · 3 KB
/
i18nextMF2.min.js
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18nextICU=t()}(this,(function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function o(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=r(i.shift());!e[a]&&n&&(e[a]=new n),e=e[a]}return o()?{}:{obj:e,k:r(i.shift())}}var i=[],a=i.forEach,s=i.slice;var c=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.type="i18nFormat",this.mem={},this.init(null,e)}var n,i,c;return n=t,i=[{key:"init",value:function(e,t){var n=this,r=e&&e.options&&e.options.i18nFormat||{};if(this.options=function(e){return a.call(s.call(arguments,1),(function(t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n])})),e}(r,t,this.options||{},{memoize:!0,memoizeFallback:!1,bindI18n:"",bindI18nStore:"",parseErrorHandler:function(e,t,n,r){return n},parseLngForMf2:function(e){return e}}),this.formats=this.options.formats,e){var o=this.options,i=o.bindI18n,c=o.bindI18nStore,f=o.memoize;e.MessageFormat=Intl.MessageFormat,e.Mf2=this,f&&(i&&e.on(i,(function(){return n.clearCache()})),c&&e.store.on(c,(function(){return n.clearCache()})))}}},{key:"addUserDefinedFormats",value:function(e){this.formats=this.formats?r(r({},this.formats),e):e}},{key:"parse",value:function(e,t,n,r,i,a){var s,c,f,u,l=a&&a.resolved&&a.resolved.res,p=this.options.memoize&&"".concat(n,".").concat(r,".").concat(i.replace(/\./g,"###"));this.options.memoize&&(s=function(e,t){var n=o(e,t),r=n.obj,i=n.k;if(r)return r[i]}(this.mem,p));try{if(!s){var m=this.options.parseLngForMf2(n);s=new Intl.MessageFormat(e,m),this.options.memoize&&(this.options.memoizeFallback||!a||l)&&(c=this.mem,f=s,(u=o(c,p,Object)).obj[u.k]=f)}return s.format(t)}catch(n){return this.options.parseErrorHandler(n,i,e,t)}}},{key:"addLookupKeys",value:function(e,t,n,r,o){return e}},{key:"clearCache",value:function(){this.mem={}}}],i&&e(n.prototype,i),c&&e(n,c),t}();return c.type="i18nFormat",c}));