UNPKG

t8on

Version:

Set up, format and translate phrases easily

1 lines 3.42 kB
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.t8on=n():t.t8on=n()}(this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r={};return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),r.d(n,"format",function(){return l}),r.d(n,"formatTo",function(){return i}),r.d(n,"formatCurrent",function(){return f}),r.d(n,"translate",function(){return s}),r.d(n,"translateTo",function(){return d}),r.d(n,"translateCurrent",function(){return p}),r.d(n,"load",function(){return m}),r.d(n,"loadRoot",function(){return h}),r.d(n,"setLocale",function(){return b}),r.d(n,"currentLocale",function(){return y}),r.d(n,"fallbackLocale",function(){return L});var e=r(1),o=r.n(e),a=r(2);r.d(n,"Translation",function(){return a.a});var u="Deprecation warning: usage of t8on singleton's properties and methods imported manually is considered deprecated. All *named* exports except Translation will be removed in upcoming major release. Please export the singleton and call its methods directly, such as t.translate()",c=new a.a,l=o()(c.format,u),i=o()(c.formatTo,u),f=o()(c.formatCurrent,u),s=o()(c.translate,u),d=o()(c.translateTo,u),p=o()(c.translateCurrent,u),m=o()(c.load,u),h=o()(c.loadRoot,u),b=o()(c.setLocale,u),y=c.currentLocale,L=c.fallbackLocale;n.default=c},function(t,n){t.exports=function(t,n){var r=!1;return function(){return r||(r=!0,console.warn(n)),t.apply(null,arguments)}}},function(t,n,r){"use strict";function e(){var t=this,n={};this.currentLocale=null,this.fallbackLocale=null,this.dictionary=function(){return n},this.load=function(r,e){return r in n||(n[r]={}),a()(n[r],e),t},this.loadRoot=function(r){return a()(n,r),t},this.setLocale=function(r,e){return n[r]=e,t},this.translate=function(r,e){return e in n&&r in n[e]?n[e][r]:t.fallbackLocale&&e!==t.fallbackLocale?t.translate(r,t.fallbackLocale):""},this.translateTo=function(n){return function(r){return t.translate(r,n)}},this.translateCurrent=function(n){return t.translate(n,t.currentLocale||"")},this.format=function(r,e){for(var o=arguments.length,a=Array(o>2?o-2:0),u=2;o>u;u++)a[u-2]=arguments[u];return e in n&&r in n[e]?n[e][r].replace(/%(\S)/g,function(t,n){return a[n]}):t.fallbackLocale&&e!==t.fallbackLocale?t.format.apply(t,[r,t.fallbackLocale].concat(a)):""},this.formatTo=function(n){return function(r){for(var e=arguments.length,o=Array(e>1?e-1:0),a=1;e>a;a++)o[a-1]=arguments[a];return t.format.apply(t,[r,n].concat(o))}},this.formatCurrent=function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),o=1;r>o;o++)e[o-1]=arguments[o];return t.format.apply(t,[n,t.currentLocale||""].concat(e))}}n.a=e;var o=r(3),a=r.n(o)},function(t,n){t.exports=function t(n,r){if(void 0===r||null===r)return n;for(var e,o,a,u=Object.keys(r),c=u.length,l=0;c>l;++l)a=u[l],o=r[a],void 0!==o&&(e=n[a],"object"==typeof o&&null!==o&&"object"==typeof e&&null!==e?t(e,o):n[a]=o);return n}}])});