intl-messageformat 9.8.0 → 9.9.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/intl-messageformat.esm.js +55 -46
- package/intl-messageformat.iife.js +0 -6
- package/lib/src/core.d.ts.map +1 -1
- package/lib/src/core.js +0 -3
- package/package.json +3 -3
- package/src/core.d.ts.map +1 -1
- package/src/core.js +0 -3
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// node_modules/tslib/tslib.es6.js
|
|
2
9
|
var __assign = function() {
|
|
3
10
|
__assign = Object.assign || function __assign2(t) {
|
|
@@ -1309,9 +1316,6 @@ var serializerDefault = function() {
|
|
|
1309
1316
|
function ObjectWithoutPrototypeCache() {
|
|
1310
1317
|
this.cache = Object.create(null);
|
|
1311
1318
|
}
|
|
1312
|
-
ObjectWithoutPrototypeCache.prototype.has = function(key) {
|
|
1313
|
-
return key in this.cache;
|
|
1314
|
-
};
|
|
1315
1319
|
ObjectWithoutPrototypeCache.prototype.get = function(key) {
|
|
1316
1320
|
return this.cache[key];
|
|
1317
1321
|
};
|
|
@@ -1336,6 +1340,8 @@ var ErrorCode;
|
|
|
1336
1340
|
ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
|
|
1337
1341
|
})(ErrorCode || (ErrorCode = {}));
|
|
1338
1342
|
var FormatError = class extends Error {
|
|
1343
|
+
code;
|
|
1344
|
+
originalMessage;
|
|
1339
1345
|
constructor(msg, code, originalMessage) {
|
|
1340
1346
|
super(msg);
|
|
1341
1347
|
this.code = code;
|
|
@@ -1530,9 +1536,6 @@ function createFastMemoizeCache(store) {
|
|
|
1530
1536
|
return {
|
|
1531
1537
|
create() {
|
|
1532
1538
|
return {
|
|
1533
|
-
has(key) {
|
|
1534
|
-
return key in store;
|
|
1535
|
-
},
|
|
1536
1539
|
get(key) {
|
|
1537
1540
|
return store[key];
|
|
1538
1541
|
},
|
|
@@ -1563,42 +1566,24 @@ function createDefaultFormatters(cache = {
|
|
|
1563
1566
|
})
|
|
1564
1567
|
};
|
|
1565
1568
|
}
|
|
1566
|
-
var
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
const result = parts.reduce((all, part) => {
|
|
1579
|
-
if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") {
|
|
1580
|
-
all.push(part.value);
|
|
1581
|
-
} else {
|
|
1582
|
-
all[all.length - 1] += part.value;
|
|
1583
|
-
}
|
|
1584
|
-
return all;
|
|
1585
|
-
}, []);
|
|
1586
|
-
if (result.length <= 1) {
|
|
1587
|
-
return result[0] || "";
|
|
1588
|
-
}
|
|
1589
|
-
return result;
|
|
1590
|
-
};
|
|
1591
|
-
this.formatToParts = (values) => formatToParts(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message);
|
|
1592
|
-
this.resolvedOptions = () => ({
|
|
1593
|
-
locale: Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
|
|
1594
|
-
});
|
|
1595
|
-
this.getAst = () => this.ast;
|
|
1569
|
+
var _IntlMessageFormat = class {
|
|
1570
|
+
ast;
|
|
1571
|
+
locales;
|
|
1572
|
+
formatters;
|
|
1573
|
+
formats;
|
|
1574
|
+
message;
|
|
1575
|
+
formatterCache = {
|
|
1576
|
+
number: {},
|
|
1577
|
+
dateTime: {},
|
|
1578
|
+
pluralRules: {}
|
|
1579
|
+
};
|
|
1580
|
+
constructor(message, locales = _IntlMessageFormat.defaultLocale, overrideFormats, opts) {
|
|
1596
1581
|
if (typeof message === "string") {
|
|
1597
1582
|
this.message = message;
|
|
1598
|
-
if (!
|
|
1583
|
+
if (!_IntlMessageFormat.__parse) {
|
|
1599
1584
|
throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
|
|
1600
1585
|
}
|
|
1601
|
-
this.ast =
|
|
1586
|
+
this.ast = _IntlMessageFormat.__parse(message, {
|
|
1602
1587
|
ignoreTag: opts?.ignoreTag
|
|
1603
1588
|
});
|
|
1604
1589
|
} else {
|
|
@@ -1607,20 +1592,44 @@ var IntlMessageFormat = class {
|
|
|
1607
1592
|
if (!Array.isArray(this.ast)) {
|
|
1608
1593
|
throw new TypeError("A message must be provided as a String or AST.");
|
|
1609
1594
|
}
|
|
1610
|
-
this.formats = mergeConfigs(
|
|
1595
|
+
this.formats = mergeConfigs(_IntlMessageFormat.formats, overrideFormats);
|
|
1611
1596
|
this.locales = locales;
|
|
1612
1597
|
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
1613
1598
|
}
|
|
1599
|
+
format = (values) => {
|
|
1600
|
+
const parts = this.formatToParts(values);
|
|
1601
|
+
if (parts.length === 1) {
|
|
1602
|
+
return parts[0].value;
|
|
1603
|
+
}
|
|
1604
|
+
const result = parts.reduce((all, part) => {
|
|
1605
|
+
if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") {
|
|
1606
|
+
all.push(part.value);
|
|
1607
|
+
} else {
|
|
1608
|
+
all[all.length - 1] += part.value;
|
|
1609
|
+
}
|
|
1610
|
+
return all;
|
|
1611
|
+
}, []);
|
|
1612
|
+
if (result.length <= 1) {
|
|
1613
|
+
return result[0] || "";
|
|
1614
|
+
}
|
|
1615
|
+
return result;
|
|
1616
|
+
};
|
|
1617
|
+
formatToParts = (values) => formatToParts(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message);
|
|
1618
|
+
resolvedOptions = () => ({
|
|
1619
|
+
locale: Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
|
|
1620
|
+
});
|
|
1621
|
+
getAst = () => this.ast;
|
|
1614
1622
|
static get defaultLocale() {
|
|
1615
|
-
if (!
|
|
1616
|
-
|
|
1623
|
+
if (!_IntlMessageFormat.memoizedDefaultLocale) {
|
|
1624
|
+
_IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
1617
1625
|
}
|
|
1618
|
-
return
|
|
1626
|
+
return _IntlMessageFormat.memoizedDefaultLocale;
|
|
1619
1627
|
}
|
|
1620
1628
|
};
|
|
1621
|
-
IntlMessageFormat
|
|
1622
|
-
IntlMessageFormat
|
|
1623
|
-
IntlMessageFormat
|
|
1629
|
+
var IntlMessageFormat = _IntlMessageFormat;
|
|
1630
|
+
__publicField(IntlMessageFormat, "memoizedDefaultLocale", null);
|
|
1631
|
+
__publicField(IntlMessageFormat, "__parse", parse);
|
|
1632
|
+
__publicField(IntlMessageFormat, "formats", {
|
|
1624
1633
|
number: {
|
|
1625
1634
|
integer: {
|
|
1626
1635
|
maximumFractionDigits: 0
|
|
@@ -1678,7 +1687,7 @@ IntlMessageFormat.formats = {
|
|
|
1678
1687
|
timeZoneName: "short"
|
|
1679
1688
|
}
|
|
1680
1689
|
}
|
|
1681
|
-
};
|
|
1690
|
+
});
|
|
1682
1691
|
|
|
1683
1692
|
// bazel-out/darwin-fastbuild/bin/packages/intl-messageformat/lib_esnext/index.js
|
|
1684
1693
|
var lib_esnext_default = IntlMessageFormat;
|
|
@@ -1381,9 +1381,6 @@ var IntlMessageFormat = (function() {
|
|
|
1381
1381
|
function ObjectWithoutPrototypeCache() {
|
|
1382
1382
|
this.cache = Object.create(null);
|
|
1383
1383
|
}
|
|
1384
|
-
ObjectWithoutPrototypeCache.prototype.has = function(key) {
|
|
1385
|
-
return key in this.cache;
|
|
1386
|
-
};
|
|
1387
1384
|
ObjectWithoutPrototypeCache.prototype.get = function(key) {
|
|
1388
1385
|
return this.cache[key];
|
|
1389
1386
|
};
|
|
@@ -1605,9 +1602,6 @@ var IntlMessageFormat = (function() {
|
|
|
1605
1602
|
return {
|
|
1606
1603
|
create: function() {
|
|
1607
1604
|
return {
|
|
1608
|
-
has: function(key) {
|
|
1609
|
-
return key in store;
|
|
1610
|
-
},
|
|
1611
1605
|
get: function(key) {
|
|
1612
1606
|
return store[key];
|
|
1613
1607
|
},
|
package/lib/src/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-messageformat/src/core.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAE,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAEL,UAAU,EACV,OAAO,EAEP,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAElB,MAAM,cAAc,CAAA;AAsCrB,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-messageformat/src/core.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAE,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAEL,UAAU,EACV,OAAO,EAEP,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAElB,MAAM,cAAc,CAAA;AAsCrB,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAwCD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAI9B;gBAEC,OAAO,EAAE,MAAM,GAAG,oBAAoB,EAAE,EACxC,OAAO,GAAE,MAAM,GAAG,MAAM,EAAoC,EAC5D,eAAe,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAClC,IAAI,CAAC,EAAE,OAAO;IAgChB,MAAM,yJAyBL;IACD,aAAa,6IAWV;IACH,eAAe;;MAEb;IACF,MAAM,+BAAiB;IACvB,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAsB;IAE1D,MAAM,KAAK,aAAa,WAOvB;IACD,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,GAAG,SAAS,CAAQ;IAIhD,MAAM,CAAC,OAAO,EAAE,OAAO,CAmEtB;CACF"}
|
package/lib/src/core.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intl-messageformat",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.1",
|
|
4
4
|
"description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"module": "lib/index.js",
|
|
32
32
|
"types": "index.d.ts",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@formatjs/fast-memoize": "1.
|
|
35
|
-
"@formatjs/icu-messageformat-parser": "2.0.
|
|
34
|
+
"@formatjs/fast-memoize": "1.2.0",
|
|
35
|
+
"@formatjs/icu-messageformat-parser": "2.0.11",
|
|
36
36
|
"tslib": "^2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
package/src/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-messageformat/src/core.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAE,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAEL,UAAU,EACV,OAAO,EAEP,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAElB,MAAM,cAAc,CAAA;AAsCrB,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-messageformat/src/core.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAE,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAEL,UAAU,EACV,OAAO,EAEP,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAElB,MAAM,cAAc,CAAA;AAsCrB,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAwCD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAI9B;gBAEC,OAAO,EAAE,MAAM,GAAG,oBAAoB,EAAE,EACxC,OAAO,GAAE,MAAM,GAAG,MAAM,EAAoC,EAC5D,eAAe,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAClC,IAAI,CAAC,EAAE,OAAO;IAgChB,MAAM,yJAyBL;IACD,aAAa,6IAWV;IACH,eAAe;;MAEb;IACF,MAAM,+BAAiB;IACvB,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAsB;IAE1D,MAAM,KAAK,aAAa,WAOvB;IACD,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,GAAG,SAAS,CAAQ;IAIhD,MAAM,CAAC,OAAO,EAAE,OAAO,CAmEtB;CACF"}
|