intl-messageformat 9.8.1 → 9.9.2
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 +77 -65
- package/intl-messageformat.iife.js +25 -24
- 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,13 @@
|
|
|
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 __require = typeof require !== "undefined" ? require : (x) => {
|
|
4
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
5
|
+
};
|
|
6
|
+
var __publicField = (obj, key, value) => {
|
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
// node_modules/tslib/tslib.es6.js
|
|
2
12
|
var __assign = function() {
|
|
3
13
|
__assign = Object.assign || function __assign2(t) {
|
|
@@ -224,7 +234,7 @@ function parseNumberSkeletonFromString(skeleton) {
|
|
|
224
234
|
throw new Error("Invalid number skeleton");
|
|
225
235
|
}
|
|
226
236
|
}
|
|
227
|
-
tokens.push({stem, options});
|
|
237
|
+
tokens.push({ stem, options });
|
|
228
238
|
}
|
|
229
239
|
return tokens;
|
|
230
240
|
}
|
|
@@ -371,12 +381,12 @@ function parseNumberSkeleton(tokens) {
|
|
|
371
381
|
result.compactDisplay = "long";
|
|
372
382
|
continue;
|
|
373
383
|
case "scientific":
|
|
374
|
-
result = __assign(__assign(__assign({}, result), {notation: "scientific"}), token.options.reduce(function(all, opt) {
|
|
384
|
+
result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
|
|
375
385
|
return __assign(__assign({}, all), parseNotationOptions(opt));
|
|
376
386
|
}, {}));
|
|
377
387
|
continue;
|
|
378
388
|
case "engineering":
|
|
379
|
-
result = __assign(__assign(__assign({}, result), {notation: "engineering"}), token.options.reduce(function(all, opt) {
|
|
389
|
+
result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
|
|
380
390
|
return __assign(__assign({}, all), parseNotationOptions(opt));
|
|
381
391
|
}, {}));
|
|
382
392
|
continue;
|
|
@@ -465,7 +475,7 @@ var _a;
|
|
|
465
475
|
var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
|
|
466
476
|
var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
|
|
467
477
|
function createLocation(start, end) {
|
|
468
|
-
return {start, end};
|
|
478
|
+
return { start, end };
|
|
469
479
|
}
|
|
470
480
|
var hasNativeStartsWith = !!String.prototype.startsWith;
|
|
471
481
|
var hasNativeFromCodePoint = !!String.fromCodePoint;
|
|
@@ -569,7 +579,7 @@ var Parser = function() {
|
|
|
569
579
|
options = {};
|
|
570
580
|
}
|
|
571
581
|
this.message = message;
|
|
572
|
-
this.position = {offset: 0, line: 1, column: 1};
|
|
582
|
+
this.position = { offset: 0, line: 1, column: 1 };
|
|
573
583
|
this.ignoreTag = !!options.ignoreTag;
|
|
574
584
|
this.requiresOtherClause = !!options.requiresOtherClause;
|
|
575
585
|
this.shouldParseSkeletons = !!options.shouldParseSkeletons;
|
|
@@ -619,7 +629,7 @@ var Parser = function() {
|
|
|
619
629
|
elements.push(result.val);
|
|
620
630
|
}
|
|
621
631
|
}
|
|
622
|
-
return {val: elements, err: null};
|
|
632
|
+
return { val: elements, err: null };
|
|
623
633
|
};
|
|
624
634
|
Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
|
|
625
635
|
var startPosition = this.clonePosition();
|
|
@@ -702,7 +712,7 @@ var Parser = function() {
|
|
|
702
712
|
}
|
|
703
713
|
var location = createLocation(start, this.clonePosition());
|
|
704
714
|
return {
|
|
705
|
-
val: {type: TYPE.literal, value, location},
|
|
715
|
+
val: { type: TYPE.literal, value, location },
|
|
706
716
|
err: null
|
|
707
717
|
};
|
|
708
718
|
};
|
|
@@ -818,7 +828,7 @@ var Parser = function() {
|
|
|
818
828
|
this.bumpTo(endOffset);
|
|
819
829
|
var endPosition = this.clonePosition();
|
|
820
830
|
var location = createLocation(startingPosition, endPosition);
|
|
821
|
-
return {value, location};
|
|
831
|
+
return { value, location };
|
|
822
832
|
};
|
|
823
833
|
Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
|
824
834
|
var _a2;
|
|
@@ -845,7 +855,7 @@ var Parser = function() {
|
|
|
845
855
|
return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
846
856
|
}
|
|
847
857
|
var styleLocation = createLocation(styleStartPosition, this.clonePosition());
|
|
848
|
-
styleAndLocation = {style, styleLocation};
|
|
858
|
+
styleAndLocation = { style, styleLocation };
|
|
849
859
|
}
|
|
850
860
|
var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
851
861
|
if (argCloseResult.err) {
|
|
@@ -860,7 +870,7 @@ var Parser = function() {
|
|
|
860
870
|
return result;
|
|
861
871
|
}
|
|
862
872
|
return {
|
|
863
|
-
val: {type: TYPE.number, value, location: location_1, style: result.val},
|
|
873
|
+
val: { type: TYPE.number, value, location: location_1, style: result.val },
|
|
864
874
|
err: null
|
|
865
875
|
};
|
|
866
876
|
} else {
|
|
@@ -875,7 +885,7 @@ var Parser = function() {
|
|
|
875
885
|
};
|
|
876
886
|
var type = argType === "date" ? TYPE.date : TYPE.time;
|
|
877
887
|
return {
|
|
878
|
-
val: {type, value, location: location_1, style},
|
|
888
|
+
val: { type, value, location: location_1, style },
|
|
879
889
|
err: null
|
|
880
890
|
};
|
|
881
891
|
}
|
|
@@ -956,7 +966,7 @@ var Parser = function() {
|
|
|
956
966
|
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
957
967
|
}
|
|
958
968
|
this.bump();
|
|
959
|
-
return {val: true, err: null};
|
|
969
|
+
return { val: true, err: null };
|
|
960
970
|
};
|
|
961
971
|
Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
|
|
962
972
|
var nestedBraces = 0;
|
|
@@ -1072,7 +1082,7 @@ var Parser = function() {
|
|
|
1072
1082
|
if (this.requiresOtherClause && !hasOtherClause) {
|
|
1073
1083
|
return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
1074
1084
|
}
|
|
1075
|
-
return {val: options, err: null};
|
|
1085
|
+
return { val: options, err: null };
|
|
1076
1086
|
};
|
|
1077
1087
|
Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
|
|
1078
1088
|
var sign = 1;
|
|
@@ -1101,7 +1111,7 @@ var Parser = function() {
|
|
|
1101
1111
|
if (!isSafeInteger(decimal)) {
|
|
1102
1112
|
return this.error(invalidNumberError, location);
|
|
1103
1113
|
}
|
|
1104
|
-
return {val: decimal, err: null};
|
|
1114
|
+
return { val: decimal, err: null };
|
|
1105
1115
|
};
|
|
1106
1116
|
Parser2.prototype.offset = function() {
|
|
1107
1117
|
return this.position.offset;
|
|
@@ -1244,7 +1254,7 @@ function parse(message, opts) {
|
|
|
1244
1254
|
if (opts === void 0) {
|
|
1245
1255
|
opts = {};
|
|
1246
1256
|
}
|
|
1247
|
-
opts = __assign({shouldParseSkeletons: true, requiresOtherClause: true}, opts);
|
|
1257
|
+
opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
|
|
1248
1258
|
var result = new Parser(message, opts).parse();
|
|
1249
1259
|
if (result.err) {
|
|
1250
1260
|
var error = SyntaxError(ErrorKind[result.err.kind]);
|
|
@@ -1309,9 +1319,6 @@ var serializerDefault = function() {
|
|
|
1309
1319
|
function ObjectWithoutPrototypeCache() {
|
|
1310
1320
|
this.cache = Object.create(null);
|
|
1311
1321
|
}
|
|
1312
|
-
ObjectWithoutPrototypeCache.prototype.has = function(key) {
|
|
1313
|
-
return key in this.cache;
|
|
1314
|
-
};
|
|
1315
1322
|
ObjectWithoutPrototypeCache.prototype.get = function(key) {
|
|
1316
1323
|
return this.cache[key];
|
|
1317
1324
|
};
|
|
@@ -1336,6 +1343,8 @@ var ErrorCode;
|
|
|
1336
1343
|
ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
|
|
1337
1344
|
})(ErrorCode || (ErrorCode = {}));
|
|
1338
1345
|
var FormatError = class extends Error {
|
|
1346
|
+
code;
|
|
1347
|
+
originalMessage;
|
|
1339
1348
|
constructor(msg, code, originalMessage) {
|
|
1340
1349
|
super(msg);
|
|
1341
1350
|
this.code = code;
|
|
@@ -1411,7 +1420,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
|
|
|
1411
1420
|
}
|
|
1412
1421
|
continue;
|
|
1413
1422
|
}
|
|
1414
|
-
const {value: varName} = el;
|
|
1423
|
+
const { value: varName } = el;
|
|
1415
1424
|
if (!(values && varName in values)) {
|
|
1416
1425
|
throw new MissingValueError(varName, originalMessage);
|
|
1417
1426
|
}
|
|
@@ -1454,7 +1463,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
|
|
|
1454
1463
|
continue;
|
|
1455
1464
|
}
|
|
1456
1465
|
if (isTagElement(el)) {
|
|
1457
|
-
const {children, value: value2} = el;
|
|
1466
|
+
const { children, value: value2 } = el;
|
|
1458
1467
|
const formatFn = values[value2];
|
|
1459
1468
|
if (!isFormatXMLElementFn(formatFn)) {
|
|
1460
1469
|
throw new InvalidValueTypeError(value2, "function", originalMessage);
|
|
@@ -1487,7 +1496,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
|
|
|
1487
1496
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
1488
1497
|
`, ErrorCode.MISSING_INTL_API, originalMessage);
|
|
1489
1498
|
}
|
|
1490
|
-
const rule = formatters.getPluralRules(locales, {type: el.pluralType}).select(value - (el.offset || 0));
|
|
1499
|
+
const rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
|
|
1491
1500
|
opt = el.options[rule] || el.options.other;
|
|
1492
1501
|
}
|
|
1493
1502
|
if (!opt) {
|
|
@@ -1524,15 +1533,12 @@ function mergeConfigs(defaultConfig, configs) {
|
|
|
1524
1533
|
return Object.keys(defaultConfig).reduce((all, k) => {
|
|
1525
1534
|
all[k] = mergeConfig(defaultConfig[k], configs[k]);
|
|
1526
1535
|
return all;
|
|
1527
|
-
}, {...defaultConfig});
|
|
1536
|
+
}, { ...defaultConfig });
|
|
1528
1537
|
}
|
|
1529
1538
|
function createFastMemoizeCache(store) {
|
|
1530
1539
|
return {
|
|
1531
1540
|
create() {
|
|
1532
1541
|
return {
|
|
1533
|
-
has(key) {
|
|
1534
|
-
return key in store;
|
|
1535
|
-
},
|
|
1536
1542
|
get(key) {
|
|
1537
1543
|
return store[key];
|
|
1538
1544
|
},
|
|
@@ -1563,42 +1569,24 @@ function createDefaultFormatters(cache = {
|
|
|
1563
1569
|
})
|
|
1564
1570
|
};
|
|
1565
1571
|
}
|
|
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;
|
|
1572
|
+
var _IntlMessageFormat = class {
|
|
1573
|
+
ast;
|
|
1574
|
+
locales;
|
|
1575
|
+
formatters;
|
|
1576
|
+
formats;
|
|
1577
|
+
message;
|
|
1578
|
+
formatterCache = {
|
|
1579
|
+
number: {},
|
|
1580
|
+
dateTime: {},
|
|
1581
|
+
pluralRules: {}
|
|
1582
|
+
};
|
|
1583
|
+
constructor(message, locales = _IntlMessageFormat.defaultLocale, overrideFormats, opts) {
|
|
1596
1584
|
if (typeof message === "string") {
|
|
1597
1585
|
this.message = message;
|
|
1598
|
-
if (!
|
|
1586
|
+
if (!_IntlMessageFormat.__parse) {
|
|
1599
1587
|
throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
|
|
1600
1588
|
}
|
|
1601
|
-
this.ast =
|
|
1589
|
+
this.ast = _IntlMessageFormat.__parse(message, {
|
|
1602
1590
|
ignoreTag: opts?.ignoreTag
|
|
1603
1591
|
});
|
|
1604
1592
|
} else {
|
|
@@ -1607,20 +1595,44 @@ var IntlMessageFormat = class {
|
|
|
1607
1595
|
if (!Array.isArray(this.ast)) {
|
|
1608
1596
|
throw new TypeError("A message must be provided as a String or AST.");
|
|
1609
1597
|
}
|
|
1610
|
-
this.formats = mergeConfigs(
|
|
1598
|
+
this.formats = mergeConfigs(_IntlMessageFormat.formats, overrideFormats);
|
|
1611
1599
|
this.locales = locales;
|
|
1612
1600
|
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
1613
1601
|
}
|
|
1602
|
+
format = (values) => {
|
|
1603
|
+
const parts = this.formatToParts(values);
|
|
1604
|
+
if (parts.length === 1) {
|
|
1605
|
+
return parts[0].value;
|
|
1606
|
+
}
|
|
1607
|
+
const result = parts.reduce((all, part) => {
|
|
1608
|
+
if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") {
|
|
1609
|
+
all.push(part.value);
|
|
1610
|
+
} else {
|
|
1611
|
+
all[all.length - 1] += part.value;
|
|
1612
|
+
}
|
|
1613
|
+
return all;
|
|
1614
|
+
}, []);
|
|
1615
|
+
if (result.length <= 1) {
|
|
1616
|
+
return result[0] || "";
|
|
1617
|
+
}
|
|
1618
|
+
return result;
|
|
1619
|
+
};
|
|
1620
|
+
formatToParts = (values) => formatToParts(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message);
|
|
1621
|
+
resolvedOptions = () => ({
|
|
1622
|
+
locale: Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
|
|
1623
|
+
});
|
|
1624
|
+
getAst = () => this.ast;
|
|
1614
1625
|
static get defaultLocale() {
|
|
1615
|
-
if (!
|
|
1616
|
-
|
|
1626
|
+
if (!_IntlMessageFormat.memoizedDefaultLocale) {
|
|
1627
|
+
_IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
1617
1628
|
}
|
|
1618
|
-
return
|
|
1629
|
+
return _IntlMessageFormat.memoizedDefaultLocale;
|
|
1619
1630
|
}
|
|
1620
1631
|
};
|
|
1621
|
-
IntlMessageFormat
|
|
1622
|
-
IntlMessageFormat
|
|
1623
|
-
IntlMessageFormat
|
|
1632
|
+
var IntlMessageFormat = _IntlMessageFormat;
|
|
1633
|
+
__publicField(IntlMessageFormat, "memoizedDefaultLocale", null);
|
|
1634
|
+
__publicField(IntlMessageFormat, "__parse", parse);
|
|
1635
|
+
__publicField(IntlMessageFormat, "formats", {
|
|
1624
1636
|
number: {
|
|
1625
1637
|
integer: {
|
|
1626
1638
|
maximumFractionDigits: 0
|
|
@@ -1678,7 +1690,7 @@ IntlMessageFormat.formats = {
|
|
|
1678
1690
|
timeZoneName: "short"
|
|
1679
1691
|
}
|
|
1680
1692
|
}
|
|
1681
|
-
};
|
|
1693
|
+
});
|
|
1682
1694
|
|
|
1683
1695
|
// bazel-out/darwin-fastbuild/bin/packages/intl-messageformat/lib_esnext/index.js
|
|
1684
1696
|
var lib_esnext_default = IntlMessageFormat;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
var IntlMessageFormat = (function() {
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __markAsModule = function(target) {
|
|
4
|
+
return __defProp(target, "__esModule", { value: true });
|
|
5
|
+
};
|
|
6
|
+
var __require = typeof require !== "undefined" ? require : function(x) {
|
|
7
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
};
|
|
3
9
|
var __export = function(target, all) {
|
|
10
|
+
__markAsModule(target);
|
|
4
11
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
13
|
};
|
|
7
14
|
|
|
8
15
|
// bazel-out/darwin-fastbuild/bin/packages/intl-messageformat/lib/index.js
|
|
@@ -42,7 +49,7 @@ var IntlMessageFormat = (function() {
|
|
|
42
49
|
|
|
43
50
|
// node_modules/tslib/tslib.es6.js
|
|
44
51
|
var extendStatics = function(d, b) {
|
|
45
|
-
extendStatics = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(d2, b2) {
|
|
52
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
46
53
|
d2.__proto__ = b2;
|
|
47
54
|
} || function(d2, b2) {
|
|
48
55
|
for (var p in b2)
|
|
@@ -296,7 +303,7 @@ var IntlMessageFormat = (function() {
|
|
|
296
303
|
throw new Error("Invalid number skeleton");
|
|
297
304
|
}
|
|
298
305
|
}
|
|
299
|
-
tokens.push({stem: stem, options: options});
|
|
306
|
+
tokens.push({ stem: stem, options: options });
|
|
300
307
|
}
|
|
301
308
|
return tokens;
|
|
302
309
|
}
|
|
@@ -443,12 +450,12 @@ var IntlMessageFormat = (function() {
|
|
|
443
450
|
result.compactDisplay = "long";
|
|
444
451
|
continue;
|
|
445
452
|
case "scientific":
|
|
446
|
-
result = __assign(__assign(__assign({}, result), {notation: "scientific"}), token.options.reduce(function(all, opt) {
|
|
453
|
+
result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
|
|
447
454
|
return __assign(__assign({}, all), parseNotationOptions(opt));
|
|
448
455
|
}, {}));
|
|
449
456
|
continue;
|
|
450
457
|
case "engineering":
|
|
451
|
-
result = __assign(__assign(__assign({}, result), {notation: "engineering"}), token.options.reduce(function(all, opt) {
|
|
458
|
+
result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
|
|
452
459
|
return __assign(__assign({}, all), parseNotationOptions(opt));
|
|
453
460
|
}, {}));
|
|
454
461
|
continue;
|
|
@@ -537,7 +544,7 @@ var IntlMessageFormat = (function() {
|
|
|
537
544
|
var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
|
|
538
545
|
var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
|
|
539
546
|
function createLocation(start, end) {
|
|
540
|
-
return {start: start, end: end};
|
|
547
|
+
return { start: start, end: end };
|
|
541
548
|
}
|
|
542
549
|
var hasNativeStartsWith = !!String.prototype.startsWith;
|
|
543
550
|
var hasNativeFromCodePoint = !!String.fromCodePoint;
|
|
@@ -641,7 +648,7 @@ var IntlMessageFormat = (function() {
|
|
|
641
648
|
options = {};
|
|
642
649
|
}
|
|
643
650
|
this.message = message;
|
|
644
|
-
this.position = {offset: 0, line: 1, column: 1};
|
|
651
|
+
this.position = { offset: 0, line: 1, column: 1 };
|
|
645
652
|
this.ignoreTag = !!options.ignoreTag;
|
|
646
653
|
this.requiresOtherClause = !!options.requiresOtherClause;
|
|
647
654
|
this.shouldParseSkeletons = !!options.shouldParseSkeletons;
|
|
@@ -691,7 +698,7 @@ var IntlMessageFormat = (function() {
|
|
|
691
698
|
elements.push(result.val);
|
|
692
699
|
}
|
|
693
700
|
}
|
|
694
|
-
return {val: elements, err: null};
|
|
701
|
+
return { val: elements, err: null };
|
|
695
702
|
};
|
|
696
703
|
Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
|
|
697
704
|
var startPosition = this.clonePosition();
|
|
@@ -774,7 +781,7 @@ var IntlMessageFormat = (function() {
|
|
|
774
781
|
}
|
|
775
782
|
var location = createLocation(start, this.clonePosition());
|
|
776
783
|
return {
|
|
777
|
-
val: {type: TYPE.literal, value: value, location: location},
|
|
784
|
+
val: { type: TYPE.literal, value: value, location: location },
|
|
778
785
|
err: null
|
|
779
786
|
};
|
|
780
787
|
};
|
|
@@ -890,7 +897,7 @@ var IntlMessageFormat = (function() {
|
|
|
890
897
|
this.bumpTo(endOffset);
|
|
891
898
|
var endPosition = this.clonePosition();
|
|
892
899
|
var location = createLocation(startingPosition, endPosition);
|
|
893
|
-
return {value: value, location: location};
|
|
900
|
+
return { value: value, location: location };
|
|
894
901
|
};
|
|
895
902
|
Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
|
896
903
|
var _a2;
|
|
@@ -917,7 +924,7 @@ var IntlMessageFormat = (function() {
|
|
|
917
924
|
return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
918
925
|
}
|
|
919
926
|
var styleLocation = createLocation(styleStartPosition, this.clonePosition());
|
|
920
|
-
styleAndLocation = {style: style, styleLocation: styleLocation};
|
|
927
|
+
styleAndLocation = { style: style, styleLocation: styleLocation };
|
|
921
928
|
}
|
|
922
929
|
var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
923
930
|
if (argCloseResult.err) {
|
|
@@ -932,7 +939,7 @@ var IntlMessageFormat = (function() {
|
|
|
932
939
|
return result;
|
|
933
940
|
}
|
|
934
941
|
return {
|
|
935
|
-
val: {type: TYPE.number, value: value, location: location_1, style: result.val},
|
|
942
|
+
val: { type: TYPE.number, value: value, location: location_1, style: result.val },
|
|
936
943
|
err: null
|
|
937
944
|
};
|
|
938
945
|
} else {
|
|
@@ -947,7 +954,7 @@ var IntlMessageFormat = (function() {
|
|
|
947
954
|
};
|
|
948
955
|
var type = argType === "date" ? TYPE.date : TYPE.time;
|
|
949
956
|
return {
|
|
950
|
-
val: {type: type, value: value, location: location_1, style: style},
|
|
957
|
+
val: { type: type, value: value, location: location_1, style: style },
|
|
951
958
|
err: null
|
|
952
959
|
};
|
|
953
960
|
}
|
|
@@ -1028,7 +1035,7 @@ var IntlMessageFormat = (function() {
|
|
|
1028
1035
|
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
1029
1036
|
}
|
|
1030
1037
|
this.bump();
|
|
1031
|
-
return {val: true, err: null};
|
|
1038
|
+
return { val: true, err: null };
|
|
1032
1039
|
};
|
|
1033
1040
|
Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
|
|
1034
1041
|
var nestedBraces = 0;
|
|
@@ -1144,7 +1151,7 @@ var IntlMessageFormat = (function() {
|
|
|
1144
1151
|
if (this.requiresOtherClause && !hasOtherClause) {
|
|
1145
1152
|
return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
1146
1153
|
}
|
|
1147
|
-
return {val: options, err: null};
|
|
1154
|
+
return { val: options, err: null };
|
|
1148
1155
|
};
|
|
1149
1156
|
Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
|
|
1150
1157
|
var sign = 1;
|
|
@@ -1173,7 +1180,7 @@ var IntlMessageFormat = (function() {
|
|
|
1173
1180
|
if (!isSafeInteger(decimal)) {
|
|
1174
1181
|
return this.error(invalidNumberError, location);
|
|
1175
1182
|
}
|
|
1176
|
-
return {val: decimal, err: null};
|
|
1183
|
+
return { val: decimal, err: null };
|
|
1177
1184
|
};
|
|
1178
1185
|
Parser2.prototype.offset = function() {
|
|
1179
1186
|
return this.position.offset;
|
|
@@ -1316,7 +1323,7 @@ var IntlMessageFormat = (function() {
|
|
|
1316
1323
|
if (opts === void 0) {
|
|
1317
1324
|
opts = {};
|
|
1318
1325
|
}
|
|
1319
|
-
opts = __assign({shouldParseSkeletons: true, requiresOtherClause: true}, opts);
|
|
1326
|
+
opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
|
|
1320
1327
|
var result = new Parser(message, opts).parse();
|
|
1321
1328
|
if (result.err) {
|
|
1322
1329
|
var error = SyntaxError(ErrorKind[result.err.kind]);
|
|
@@ -1381,9 +1388,6 @@ var IntlMessageFormat = (function() {
|
|
|
1381
1388
|
function ObjectWithoutPrototypeCache() {
|
|
1382
1389
|
this.cache = Object.create(null);
|
|
1383
1390
|
}
|
|
1384
|
-
ObjectWithoutPrototypeCache.prototype.has = function(key) {
|
|
1385
|
-
return key in this.cache;
|
|
1386
|
-
};
|
|
1387
1391
|
ObjectWithoutPrototypeCache.prototype.get = function(key) {
|
|
1388
1392
|
return this.cache[key];
|
|
1389
1393
|
};
|
|
@@ -1569,7 +1573,7 @@ var IntlMessageFormat = (function() {
|
|
|
1569
1573
|
if (!Intl.PluralRules) {
|
|
1570
1574
|
throw new FormatError('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n', ErrorCode.MISSING_INTL_API, originalMessage);
|
|
1571
1575
|
}
|
|
1572
|
-
var rule = formatters.getPluralRules(locales, {type: el.pluralType}).select(value - (el.offset || 0));
|
|
1576
|
+
var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
|
|
1573
1577
|
opt = el.options[rule] || el.options.other;
|
|
1574
1578
|
}
|
|
1575
1579
|
if (!opt) {
|
|
@@ -1605,9 +1609,6 @@ var IntlMessageFormat = (function() {
|
|
|
1605
1609
|
return {
|
|
1606
1610
|
create: function() {
|
|
1607
1611
|
return {
|
|
1608
|
-
has: function(key) {
|
|
1609
|
-
return key in store;
|
|
1610
|
-
},
|
|
1611
1612
|
get: function(key) {
|
|
1612
1613
|
return store[key];
|
|
1613
1614
|
},
|
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.2",
|
|
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.12",
|
|
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"}
|