@lingui/core 3.10.4 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/context.d.ts +1 -0
- package/cjs/context.d.ts.map +1 -1
- package/cjs/core.development.js +4 -2
- package/cjs/core.development.js.map +1 -1
- package/cjs/core.production.min.js +1 -1
- package/cjs/dev.development.js +4 -2
- package/cjs/dev.development.js.map +1 -1
- package/cjs/dev.production.min.js +1 -1
- package/esm/context.d.ts +1 -0
- package/esm/context.d.ts.map +1 -1
- package/esm/core.development.js +4 -2
- package/esm/core.development.js.map +1 -1
- package/esm/core.production.min.js +1 -1
- package/esm/dev.development.js +4 -2
- package/esm/dev.development.js.map +1 -1
- package/esm/dev.production.min.js +1 -1
- package/package.json +2 -1
package/cjs/context.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CompiledMessage, Locales } from "./i18n";
|
|
2
|
+
export declare const UNICODE_REGEX: RegExp;
|
|
2
3
|
export declare function interpolate(translation: CompiledMessage, locale: string, locales: Locales, localeData: Object): (values: Object, formats?: Object) => string;
|
|
3
4
|
//# sourceMappingURL=context.d.ts.map
|
package/cjs/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["packages/core/src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["packages/core/src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIjD,eAAO,MAAM,aAAa,QAAyC,CAAC;AAuEpE,wBAAgB,WAAW,CACzB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,YAEF,MAAM,YAAW,MAAM,KAAQ,MAAM,CAsCtD"}
|
package/cjs/core.development.js
CHANGED
|
@@ -94,6 +94,8 @@ var formats = /*#__PURE__*/Object.freeze({
|
|
|
94
94
|
number: number
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
98
|
+
|
|
97
99
|
var defaultFormats = function defaultFormats(locale, locales) {
|
|
98
100
|
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
99
101
|
plurals: undefined
|
|
@@ -226,7 +228,7 @@ function interpolate(translation, locale, locales, localeData) {
|
|
|
226
228
|
};
|
|
227
229
|
|
|
228
230
|
var result = formatMessage(translation);
|
|
229
|
-
if (isString(result) &&
|
|
231
|
+
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
|
|
230
232
|
if (isString(result)) return result.trim();
|
|
231
233
|
return result;
|
|
232
234
|
};
|
|
@@ -469,7 +471,7 @@ var I18n = /*#__PURE__*/function (_EventEmitter) {
|
|
|
469
471
|
} // hack for parsing unicode values inside a string to get parsed in react native environments
|
|
470
472
|
|
|
471
473
|
|
|
472
|
-
if (isString(translation) &&
|
|
474
|
+
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
|
|
473
475
|
if (isString(translation)) return translation;
|
|
474
476
|
return interpolate(translation, this.locale, this.locales, this.localeData)(values, formats);
|
|
475
477
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),a=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/slicedToArray"),o=require("@babel/runtime/helpers/objectWithoutProperties");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),u=i(t),c=i(r),f=i(n),h=i(a),v=i(l),d=i(o),m=function(e){return"string"==typeof e},g=function(e){return"function"==typeof e},y=new Map,p=new Map;function _(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(m(n)&&(n=new Date(n)),r){var a=D(e,t),l=p.get(a);if(l)return l.format(n);var o=new Intl.DateTimeFormat(e,t);return p.set(a,o),o.format(n)}var i=new Intl.DateTimeFormat(e,t);return i.format(n)}}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=D(e,t),l=y.get(a);if(l)return l.format(n);var o=new Intl.NumberFormat(e,t);return y.set(a,o),o.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function D(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var k=Object.freeze({__proto__:null,date:_,number:b});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),a=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/slicedToArray"),o=require("@babel/runtime/helpers/objectWithoutProperties");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),u=i(t),c=i(r),f=i(n),h=i(a),v=i(l),d=i(o),m=function(e){return"string"==typeof e},g=function(e){return"function"==typeof e},y=new Map,p=new Map;function _(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(m(n)&&(n=new Date(n)),r){var a=D(e,t),l=p.get(a);if(l)return l.format(n);var o=new Intl.DateTimeFormat(e,t);return p.set(a,o),o.format(n)}var i=new Intl.DateTimeFormat(e,t);return i.format(n)}}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=D(e,t),l=y.get(a);if(l)return l.format(n);var o=new Intl.NumberFormat(e,t);return y.set(a,o),o.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function D(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var k=Object.freeze({__proto__:null,date:_,number:b}),A=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function O(e){var t=e.locale,r=e.locales,n=e.values,a=e.formats,l=e.localeData,o=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=t||e;var a=r.plurals,l=function(e){return m(e)?n[e]||{style:e}:e},o=function(e,r){return function(n){var a=g(r)?r(n):r,l=Array.isArray(a)?a:[a],o=b(t)(e);return l.map((function(e){return m(e)?e.replace("#",o):e}))}};return a||console.error("Plurals for locale ".concat(e," aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.")),{plural:function(e,t){var r=t.offset,n=void 0===r?0:r,l=d.default(t,["offset"]),i=l[e]||l[null==a?void 0:a(e-n)]||l.other;return o(e-n,i)},selectordinal:function(e,t){var r=t.offset,n=void 0===r?0:r,l=d.default(t,["offset"]),i=l[e]||l[null==a?void 0:a(e-n,!0)]||l.other;return o(e-n,i)},select:function(e,t){return t[e]||t.other},number:function(e,r){return b(t,l(r))(e)},date:function(e,r){return _(t,l(r))(e)},undefined:function(e){return e}}}(t,r,l,a);return function e(t,r,a){var l=n[t],i=o[r](l,a),s=g(i)?i(e):i;return Array.isArray(s)?s.join(""):s}}function j(e,t,r,n){return function(a){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=O({locale:t,locales:r,localeData:n,formats:l,values:a}),i=function e(t){return Array.isArray(t)?t.reduce((function(t,r){if(m(r))return t+r;var n=v.default(r,3),a=n[0],l=n[1],i=n[2],s={};null==i||m(i)?s=i:Object.keys(i).forEach((function(t){s[t]=e(i[t])}));var u=o(a,l,s);return null==u?t:t+u}),""):t},s=i(e);return m(s)&&A.test(s)?JSON.parse('"'.concat(s.trim(),'"')):m(s)?s.trim():s}}var w=function(){function e(){s.default(this,e),this._events={}}return u.default(e,[{key:"on",value:function(e,t){var r=this;return this._hasEvent(e)||(this._events[e]=[]),this._events[e].push(t),function(){return r.removeListener(e,t)}}},{key:"removeListener",value:function(e,t){if(this._hasEvent(e)){var r=this._events[e].indexOf(t);~r&&this._events[e].splice(r,1)}}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];this._hasEvent(e)&&this._events[e].map((function(e){return e.apply(t,n)}))}},{key:"_hasEvent",value:function(e){return Array.isArray(this._events[e])}}]),e}();function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=h.default(e);if(t){var a=h.default(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return f.default(this,r)}}var L=function(e){c.default(r,e);var t=x(r);function r(e){var n;return s.default(this,r),n=t.call(this),n._messages={},n._localeData={},null!=e.missing&&(n._missing=e.missing),null!=e.messages&&n.load(e.messages),null!=e.localeData&&n.loadLocaleData(e.localeData),null==e.locale&&null==e.locales||n.activate(e.locale,e.locales),n}return u.default(r,[{key:"_loadLocaleData",value:function(e,t){null==this._localeData[e]?this._localeData[e]=t:Object.assign(this._localeData[e],t)}},{key:"loadLocaleData",value:function(e,t){var r=this;null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((function(t){return r._loadLocaleData(t,e[t])})),this.emit("change")}},{key:"_load",value:function(e,t){null==this._messages[e]?this._messages[e]=t:Object.assign(this._messages[e],t)}},{key:"load",value:function(e,t){var r=this;null!=t?this._load(e,t):Object.keys(e).forEach((function(t){return r._load(t,e[t])})),this.emit("change")}},{key:"activate",value:function(e,t){this._locale=e,this._locales=t,this.emit("change")}},{key:"_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.message,a=r.formats;m(e)||(t=e.values||t,n=e.message,e=e.id);var l=this.messages[e]||n||e,o=this._missing;return o&&!this.messages[e]?g(o)?o(this.locale,e):o:(this.messages[e]||this.emit("missing",{id:e,locale:this._locale}),m(l)&&A.test(l)?JSON.parse('"'.concat(l,'"')):m(l)?l:j(l,this.locale,this.locales,this.localeData)(t,a))}},{key:"date",value:function(e,t){return _(this.locales||this.locale,t)(e)}},{key:"number",value:function(e,t){return b(this.locales||this.locale,t)(e)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var e;return null!==(e=this._messages[this._locale])&&void 0!==e?e:{}}},{key:"localeData",get:function(){var e;return null!==(e=this._localeData[this._locale])&&void 0!==e?e:{}}}]),r}(w);function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new L(e)}var E=q();exports.I18n=L,exports.formats=k,exports.i18n=E,exports.setupI18n=q;
|
|
2
2
|
//# sourceMappingURL=core.production.min.js.map
|
package/cjs/dev.development.js
CHANGED
|
@@ -94,6 +94,8 @@ var formats = /*#__PURE__*/Object.freeze({
|
|
|
94
94
|
number: number
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
98
|
+
|
|
97
99
|
var defaultFormats = function defaultFormats(locale, locales) {
|
|
98
100
|
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
99
101
|
plurals: undefined
|
|
@@ -226,7 +228,7 @@ function interpolate(translation, locale, locales, localeData) {
|
|
|
226
228
|
};
|
|
227
229
|
|
|
228
230
|
var result = formatMessage(translation);
|
|
229
|
-
if (isString(result) &&
|
|
231
|
+
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
|
|
230
232
|
if (isString(result)) return result.trim();
|
|
231
233
|
return result;
|
|
232
234
|
};
|
|
@@ -469,7 +471,7 @@ var I18n = /*#__PURE__*/function (_EventEmitter) {
|
|
|
469
471
|
} // hack for parsing unicode values inside a string to get parsed in react native environments
|
|
470
472
|
|
|
471
473
|
|
|
472
|
-
if (isString(translation) &&
|
|
474
|
+
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
|
|
473
475
|
if (isString(translation)) return translation;
|
|
474
476
|
return interpolate(translation, this.locale, this.locales, this.localeData)(values, formats);
|
|
475
477
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),a=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/slicedToArray"),o=require("@babel/runtime/helpers/objectWithoutProperties");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),u=i(t),c=i(r),f=i(n),h=i(a),v=i(l),d=i(o),m=function(e){return"string"==typeof e},g=function(e){return"function"==typeof e},y=new Map,p=new Map;function _(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(m(n)&&(n=new Date(n)),r){var a=D(e,t),l=p.get(a);if(l)return l.format(n);var o=new Intl.DateTimeFormat(e,t);return p.set(a,o),o.format(n)}var i=new Intl.DateTimeFormat(e,t);return i.format(n)}}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=D(e,t),l=y.get(a);if(l)return l.format(n);var o=new Intl.NumberFormat(e,t);return y.set(a,o),o.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function D(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var k=Object.freeze({__proto__:null,date:_,number:b});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),a=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/slicedToArray"),o=require("@babel/runtime/helpers/objectWithoutProperties");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),u=i(t),c=i(r),f=i(n),h=i(a),v=i(l),d=i(o),m=function(e){return"string"==typeof e},g=function(e){return"function"==typeof e},y=new Map,p=new Map;function _(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(m(n)&&(n=new Date(n)),r){var a=D(e,t),l=p.get(a);if(l)return l.format(n);var o=new Intl.DateTimeFormat(e,t);return p.set(a,o),o.format(n)}var i=new Intl.DateTimeFormat(e,t);return i.format(n)}}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=D(e,t),l=y.get(a);if(l)return l.format(n);var o=new Intl.NumberFormat(e,t);return y.set(a,o),o.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function D(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var k=Object.freeze({__proto__:null,date:_,number:b}),A=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function O(e){var t=e.locale,r=e.locales,n=e.values,a=e.formats,l=e.localeData,o=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=t||e;var a=r.plurals,l=function(e){return m(e)?n[e]||{style:e}:e},o=function(e,r){return function(n){var a=g(r)?r(n):r,l=Array.isArray(a)?a:[a],o=b(t)(e);return l.map((function(e){return m(e)?e.replace("#",o):e}))}};return a||console.error("Plurals for locale ".concat(e," aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.")),{plural:function(e,t){var r=t.offset,n=void 0===r?0:r,l=d.default(t,["offset"]),i=l[e]||l[null==a?void 0:a(e-n)]||l.other;return o(e-n,i)},selectordinal:function(e,t){var r=t.offset,n=void 0===r?0:r,l=d.default(t,["offset"]),i=l[e]||l[null==a?void 0:a(e-n,!0)]||l.other;return o(e-n,i)},select:function(e,t){return t[e]||t.other},number:function(e,r){return b(t,l(r))(e)},date:function(e,r){return _(t,l(r))(e)},undefined:function(e){return e}}}(t,r,l,a);return function e(t,r,a){var l=n[t],i=o[r](l,a),s=g(i)?i(e):i;return Array.isArray(s)?s.join(""):s}}function j(e,t,r,n){return function(a){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=O({locale:t,locales:r,localeData:n,formats:l,values:a}),i=function e(t){return Array.isArray(t)?t.reduce((function(t,r){if(m(r))return t+r;var n=v.default(r,3),a=n[0],l=n[1],i=n[2],s={};null==i||m(i)?s=i:Object.keys(i).forEach((function(t){s[t]=e(i[t])}));var u=o(a,l,s);return null==u?t:t+u}),""):t},s=i(e);return m(s)&&A.test(s)?JSON.parse('"'.concat(s.trim(),'"')):m(s)?s.trim():s}}var w=function(){function e(){s.default(this,e),this._events={}}return u.default(e,[{key:"on",value:function(e,t){var r=this;return this._hasEvent(e)||(this._events[e]=[]),this._events[e].push(t),function(){return r.removeListener(e,t)}}},{key:"removeListener",value:function(e,t){if(this._hasEvent(e)){var r=this._events[e].indexOf(t);~r&&this._events[e].splice(r,1)}}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];this._hasEvent(e)&&this._events[e].map((function(e){return e.apply(t,n)}))}},{key:"_hasEvent",value:function(e){return Array.isArray(this._events[e])}}]),e}();function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=h.default(e);if(t){var a=h.default(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return f.default(this,r)}}var L=function(e){c.default(r,e);var t=x(r);function r(e){var n;return s.default(this,r),n=t.call(this),n._messages={},n._localeData={},null!=e.missing&&(n._missing=e.missing),null!=e.messages&&n.load(e.messages),null!=e.localeData&&n.loadLocaleData(e.localeData),null==e.locale&&null==e.locales||n.activate(e.locale,e.locales),n}return u.default(r,[{key:"_loadLocaleData",value:function(e,t){null==this._localeData[e]?this._localeData[e]=t:Object.assign(this._localeData[e],t)}},{key:"loadLocaleData",value:function(e,t){var r=this;null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((function(t){return r._loadLocaleData(t,e[t])})),this.emit("change")}},{key:"_load",value:function(e,t){null==this._messages[e]?this._messages[e]=t:Object.assign(this._messages[e],t)}},{key:"load",value:function(e,t){var r=this;null!=t?this._load(e,t):Object.keys(e).forEach((function(t){return r._load(t,e[t])})),this.emit("change")}},{key:"activate",value:function(e,t){this._locale=e,this._locales=t,this.emit("change")}},{key:"_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.message,a=r.formats;m(e)||(t=e.values||t,n=e.message,e=e.id);var l=this.messages[e]||n||e,o=this._missing;return o&&!this.messages[e]?g(o)?o(this.locale,e):o:(this.messages[e]||this.emit("missing",{id:e,locale:this._locale}),m(l)&&A.test(l)?JSON.parse('"'.concat(l,'"')):m(l)?l:j(l,this.locale,this.locales,this.localeData)(t,a))}},{key:"date",value:function(e,t){return _(this.locales||this.locale,t)(e)}},{key:"number",value:function(e,t){return b(this.locales||this.locale,t)(e)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var e;return null!==(e=this._messages[this._locale])&&void 0!==e?e:{}}},{key:"localeData",get:function(){var e;return null!==(e=this._localeData[this._locale])&&void 0!==e?e:{}}}]),r}(w);function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new L(e)}var E=q();exports.I18n=L,exports.formats=k,exports.i18n=E,exports.setupI18n=q;
|
|
2
2
|
//# sourceMappingURL=dev.production.min.js.map
|
package/esm/context.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CompiledMessage, Locales } from "./i18n";
|
|
2
|
+
export declare const UNICODE_REGEX: RegExp;
|
|
2
3
|
export declare function interpolate(translation: CompiledMessage, locale: string, locales: Locales, localeData: Object): (values: Object, formats?: Object) => string;
|
|
3
4
|
//# sourceMappingURL=context.d.ts.map
|
package/esm/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["packages/core/src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["packages/core/src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIjD,eAAO,MAAM,aAAa,QAAyC,CAAC;AAuEpE,wBAAgB,WAAW,CACzB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,YAEF,MAAM,YAAW,MAAM,KAAQ,MAAM,CAsCtD"}
|
package/esm/core.development.js
CHANGED
|
@@ -79,6 +79,8 @@ var formats = /*#__PURE__*/Object.freeze({
|
|
|
79
79
|
number: number
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
83
|
+
|
|
82
84
|
var defaultFormats = function defaultFormats(locale, locales) {
|
|
83
85
|
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
84
86
|
plurals: undefined
|
|
@@ -211,7 +213,7 @@ function interpolate(translation, locale, locales, localeData) {
|
|
|
211
213
|
};
|
|
212
214
|
|
|
213
215
|
var result = formatMessage(translation);
|
|
214
|
-
if (isString(result) &&
|
|
216
|
+
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
|
|
215
217
|
if (isString(result)) return result.trim();
|
|
216
218
|
return result;
|
|
217
219
|
};
|
|
@@ -454,7 +456,7 @@ var I18n = /*#__PURE__*/function (_EventEmitter) {
|
|
|
454
456
|
} // hack for parsing unicode values inside a string to get parsed in react native environments
|
|
455
457
|
|
|
456
458
|
|
|
457
|
-
if (isString(translation) &&
|
|
459
|
+
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
|
|
458
460
|
if (isString(translation)) return translation;
|
|
459
461
|
return interpolate(translation, this.locale, this.locales, this.localeData)(values, formats);
|
|
460
462
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/inherits";import n from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import o from"@babel/runtime/helpers/slicedToArray";import l from"@babel/runtime/helpers/objectWithoutProperties";var i=function(e){return"string"==typeof e},s=function(e){return"function"==typeof e},u=new Map,c=new Map;function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(i(n)&&(n=new Date(n)),r){var a=v(e,t),o=c.get(a);if(o)return o.format(n);var l=new Intl.DateTimeFormat(e,t);return c.set(a,l),l.format(n)}var s=new Intl.DateTimeFormat(e,t);return s.format(n)}}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=v(e,t),o=u.get(a);if(o)return o.format(n);var l=new Intl.NumberFormat(e,t);return u.set(a,l),l.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var m=Object.freeze({__proto__:null,date:f,number:h});function
|
|
1
|
+
import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/inherits";import n from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import o from"@babel/runtime/helpers/slicedToArray";import l from"@babel/runtime/helpers/objectWithoutProperties";var i=function(e){return"string"==typeof e},s=function(e){return"function"==typeof e},u=new Map,c=new Map;function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(i(n)&&(n=new Date(n)),r){var a=v(e,t),o=c.get(a);if(o)return o.format(n);var l=new Intl.DateTimeFormat(e,t);return c.set(a,l),l.format(n)}var s=new Intl.DateTimeFormat(e,t);return s.format(n)}}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=v(e,t),o=u.get(a);if(o)return o.format(n);var l=new Intl.NumberFormat(e,t);return u.set(a,l),l.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var m=Object.freeze({__proto__:null,date:f,number:h}),g=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function d(e){var t=e.locale,r=e.locales,n=e.values,a=e.formats,o=e.localeData,u=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=t||e;var a=r.plurals,o=function(e){return i(e)?n[e]||{style:e}:e},u=function(e,r){return function(n){var a=s(r)?r(n):r,o=Array.isArray(a)?a:[a],l=h(t)(e);return o.map((function(e){return i(e)?e.replace("#",l):e}))}};return a||console.error("Plurals for locale ".concat(e," aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.")),{plural:function(e,t){var r=t.offset,n=void 0===r?0:r,o=l(t,["offset"]),i=o[e]||o[null==a?void 0:a(e-n)]||o.other;return u(e-n,i)},selectordinal:function(e,t){var r=t.offset,n=void 0===r?0:r,o=l(t,["offset"]),i=o[e]||o[null==a?void 0:a(e-n,!0)]||o.other;return u(e-n,i)},select:function(e,t){return t[e]||t.other},number:function(e,r){return h(t,o(r))(e)},date:function(e,r){return f(t,o(r))(e)},undefined:function(e){return e}}}(t,r,o,a);return function e(t,r,a){var o=n[t],l=u[r](o,a),i=s(l)?l(e):l;return Array.isArray(i)?i.join(""):i}}function p(e,t,r,n){return function(a){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=d({locale:t,locales:r,localeData:n,formats:l,values:a}),u=function e(t){return Array.isArray(t)?t.reduce((function(t,r){if(i(r))return t+r;var n=o(r,3),a=n[0],l=n[1],u=n[2],c={};null==u||i(u)?c=u:Object.keys(u).forEach((function(t){c[t]=e(u[t])}));var f=s(a,l,c);return null==f?t:t+f}),""):t},c=u(e);return i(c)&&g.test(c)?JSON.parse('"'.concat(c.trim(),'"')):i(c)?c.trim():c}}var y=function(){function r(){e(this,r),this._events={}}return t(r,[{key:"on",value:function(e,t){var r=this;return this._hasEvent(e)||(this._events[e]=[]),this._events[e].push(t),function(){return r.removeListener(e,t)}}},{key:"removeListener",value:function(e,t){if(this._hasEvent(e)){var r=this._events[e].indexOf(t);~r&&this._events[e].splice(r,1)}}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];this._hasEvent(e)&&this._events[e].map((function(e){return e.apply(t,n)}))}},{key:"_hasEvent",value:function(e){return Array.isArray(this._events[e])}}]),r}();function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=a(e);if(t){var l=a(this).constructor;r=Reflect.construct(o,arguments,l)}else r=o.apply(this,arguments);return n(this,r)}}var b=function(n){r(o,n);var a=_(o);function o(t){var r;return e(this,o),r=a.call(this),r._messages={},r._localeData={},null!=t.missing&&(r._missing=t.missing),null!=t.messages&&r.load(t.messages),null!=t.localeData&&r.loadLocaleData(t.localeData),null==t.locale&&null==t.locales||r.activate(t.locale,t.locales),r}return t(o,[{key:"_loadLocaleData",value:function(e,t){null==this._localeData[e]?this._localeData[e]=t:Object.assign(this._localeData[e],t)}},{key:"loadLocaleData",value:function(e,t){var r=this;null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((function(t){return r._loadLocaleData(t,e[t])})),this.emit("change")}},{key:"_load",value:function(e,t){null==this._messages[e]?this._messages[e]=t:Object.assign(this._messages[e],t)}},{key:"load",value:function(e,t){var r=this;null!=t?this._load(e,t):Object.keys(e).forEach((function(t){return r._load(t,e[t])})),this.emit("change")}},{key:"activate",value:function(e,t){this._locale=e,this._locales=t,this.emit("change")}},{key:"_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.message,a=r.formats;i(e)||(t=e.values||t,n=e.message,e=e.id);var o=this.messages[e]||n||e,l=this._missing;return l&&!this.messages[e]?s(l)?l(this.locale,e):l:(this.messages[e]||this.emit("missing",{id:e,locale:this._locale}),i(o)&&g.test(o)?JSON.parse('"'.concat(o,'"')):i(o)?o:p(o,this.locale,this.locales,this.localeData)(t,a))}},{key:"date",value:function(e,t){return f(this.locales||this.locale,t)(e)}},{key:"number",value:function(e,t){return h(this.locales||this.locale,t)(e)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var e;return null!==(e=this._messages[this._locale])&&void 0!==e?e:{}}},{key:"localeData",get:function(){var e;return null!==(e=this._localeData[this._locale])&&void 0!==e?e:{}}}]),o}(y);function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new b(e)}var k=D();export{b as I18n,m as formats,k as i18n,D as setupI18n};
|
|
2
2
|
//# sourceMappingURL=core.production.min.js.map
|
package/esm/dev.development.js
CHANGED
|
@@ -79,6 +79,8 @@ var formats = /*#__PURE__*/Object.freeze({
|
|
|
79
79
|
number: number
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
83
|
+
|
|
82
84
|
var defaultFormats = function defaultFormats(locale, locales) {
|
|
83
85
|
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
84
86
|
plurals: undefined
|
|
@@ -211,7 +213,7 @@ function interpolate(translation, locale, locales, localeData) {
|
|
|
211
213
|
};
|
|
212
214
|
|
|
213
215
|
var result = formatMessage(translation);
|
|
214
|
-
if (isString(result) &&
|
|
216
|
+
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
|
|
215
217
|
if (isString(result)) return result.trim();
|
|
216
218
|
return result;
|
|
217
219
|
};
|
|
@@ -454,7 +456,7 @@ var I18n = /*#__PURE__*/function (_EventEmitter) {
|
|
|
454
456
|
} // hack for parsing unicode values inside a string to get parsed in react native environments
|
|
455
457
|
|
|
456
458
|
|
|
457
|
-
if (isString(translation) &&
|
|
459
|
+
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
|
|
458
460
|
if (isString(translation)) return translation;
|
|
459
461
|
return interpolate(translation, this.locale, this.locales, this.localeData)(values, formats);
|
|
460
462
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/inherits";import n from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import o from"@babel/runtime/helpers/slicedToArray";import l from"@babel/runtime/helpers/objectWithoutProperties";var i=function(e){return"string"==typeof e},s=function(e){return"function"==typeof e},u=new Map,c=new Map;function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(i(n)&&(n=new Date(n)),r){var a=v(e,t),o=c.get(a);if(o)return o.format(n);var l=new Intl.DateTimeFormat(e,t);return c.set(a,l),l.format(n)}var s=new Intl.DateTimeFormat(e,t);return s.format(n)}}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=v(e,t),o=u.get(a);if(o)return o.format(n);var l=new Intl.NumberFormat(e,t);return u.set(a,l),l.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var m=Object.freeze({__proto__:null,date:f,number:h});function
|
|
1
|
+
import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/inherits";import n from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import o from"@babel/runtime/helpers/slicedToArray";import l from"@babel/runtime/helpers/objectWithoutProperties";var i=function(e){return"string"==typeof e},s=function(e){return"function"==typeof e},u=new Map,c=new Map;function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(i(n)&&(n=new Date(n)),r){var a=v(e,t),o=c.get(a);if(o)return o.format(n);var l=new Intl.DateTimeFormat(e,t);return c.set(a,l),l.format(n)}var s=new Intl.DateTimeFormat(e,t);return s.format(n)}}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){if(r){var a=v(e,t),o=u.get(a);if(o)return o.format(n);var l=new Intl.NumberFormat(e,t);return u.set(a,l),l.format(n)}var i=new Intl.NumberFormat(e,t);return i.format(n)}}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Array.isArray(e)?e.sort().join("-"):e;return"".concat(r,"-").concat(JSON.stringify(t))}var m=Object.freeze({__proto__:null,date:f,number:h}),g=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;function d(e){var t=e.locale,r=e.locales,n=e.values,a=e.formats,o=e.localeData,u=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{plurals:void 0},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=t||e;var a=r.plurals,o=function(e){return i(e)?n[e]||{style:e}:e},u=function(e,r){return function(n){var a=s(r)?r(n):r,o=Array.isArray(a)?a:[a],l=h(t)(e);return o.map((function(e){return i(e)?e.replace("#",l):e}))}};return a||console.error("Plurals for locale ".concat(e," aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.")),{plural:function(e,t){var r=t.offset,n=void 0===r?0:r,o=l(t,["offset"]),i=o[e]||o[null==a?void 0:a(e-n)]||o.other;return u(e-n,i)},selectordinal:function(e,t){var r=t.offset,n=void 0===r?0:r,o=l(t,["offset"]),i=o[e]||o[null==a?void 0:a(e-n,!0)]||o.other;return u(e-n,i)},select:function(e,t){return t[e]||t.other},number:function(e,r){return h(t,o(r))(e)},date:function(e,r){return f(t,o(r))(e)},undefined:function(e){return e}}}(t,r,o,a);return function e(t,r,a){var o=n[t],l=u[r](o,a),i=s(l)?l(e):l;return Array.isArray(i)?i.join(""):i}}function p(e,t,r,n){return function(a){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=d({locale:t,locales:r,localeData:n,formats:l,values:a}),u=function e(t){return Array.isArray(t)?t.reduce((function(t,r){if(i(r))return t+r;var n=o(r,3),a=n[0],l=n[1],u=n[2],c={};null==u||i(u)?c=u:Object.keys(u).forEach((function(t){c[t]=e(u[t])}));var f=s(a,l,c);return null==f?t:t+f}),""):t},c=u(e);return i(c)&&g.test(c)?JSON.parse('"'.concat(c.trim(),'"')):i(c)?c.trim():c}}var y=function(){function r(){e(this,r),this._events={}}return t(r,[{key:"on",value:function(e,t){var r=this;return this._hasEvent(e)||(this._events[e]=[]),this._events[e].push(t),function(){return r.removeListener(e,t)}}},{key:"removeListener",value:function(e,t){if(this._hasEvent(e)){var r=this._events[e].indexOf(t);~r&&this._events[e].splice(r,1)}}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];this._hasEvent(e)&&this._events[e].map((function(e){return e.apply(t,n)}))}},{key:"_hasEvent",value:function(e){return Array.isArray(this._events[e])}}]),r}();function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=a(e);if(t){var l=a(this).constructor;r=Reflect.construct(o,arguments,l)}else r=o.apply(this,arguments);return n(this,r)}}var b=function(n){r(o,n);var a=_(o);function o(t){var r;return e(this,o),r=a.call(this),r._messages={},r._localeData={},null!=t.missing&&(r._missing=t.missing),null!=t.messages&&r.load(t.messages),null!=t.localeData&&r.loadLocaleData(t.localeData),null==t.locale&&null==t.locales||r.activate(t.locale,t.locales),r}return t(o,[{key:"_loadLocaleData",value:function(e,t){null==this._localeData[e]?this._localeData[e]=t:Object.assign(this._localeData[e],t)}},{key:"loadLocaleData",value:function(e,t){var r=this;null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((function(t){return r._loadLocaleData(t,e[t])})),this.emit("change")}},{key:"_load",value:function(e,t){null==this._messages[e]?this._messages[e]=t:Object.assign(this._messages[e],t)}},{key:"load",value:function(e,t){var r=this;null!=t?this._load(e,t):Object.keys(e).forEach((function(t){return r._load(t,e[t])})),this.emit("change")}},{key:"activate",value:function(e,t){this._locale=e,this._locales=t,this.emit("change")}},{key:"_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.message,a=r.formats;i(e)||(t=e.values||t,n=e.message,e=e.id);var o=this.messages[e]||n||e,l=this._missing;return l&&!this.messages[e]?s(l)?l(this.locale,e):l:(this.messages[e]||this.emit("missing",{id:e,locale:this._locale}),i(o)&&g.test(o)?JSON.parse('"'.concat(o,'"')):i(o)?o:p(o,this.locale,this.locales,this.localeData)(t,a))}},{key:"date",value:function(e,t){return f(this.locales||this.locale,t)(e)}},{key:"number",value:function(e,t){return h(this.locales||this.locale,t)(e)}},{key:"locale",get:function(){return this._locale}},{key:"locales",get:function(){return this._locales}},{key:"messages",get:function(){var e;return null!==(e=this._messages[this._locale])&&void 0!==e?e:{}}},{key:"localeData",get:function(){var e;return null!==(e=this._localeData[this._locale])&&void 0!==e?e:{}}}]),o}(y);function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new b(e)}var k=D();export{b as I18n,m as formats,k as i18n,D as setupI18n};
|
|
2
2
|
//# sourceMappingURL=dev.production.min.js.map
|