@formatjs/icu-messageformat-parser 2.0.12 → 2.0.16
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/index.js +7 -7
- package/lib/manipulator.js +2 -2
- package/lib/parser.js +6 -6
- package/lib/printer.js +11 -11
- package/manipulator.js +3 -3
- package/no-parser.js +1 -1
- package/package.json +8 -3
- package/parser.js +10 -10
- package/printer.js +19 -19
package/index.js
CHANGED
|
@@ -8,27 +8,27 @@ var types_1 = require("./types");
|
|
|
8
8
|
function pruneLocation(els) {
|
|
9
9
|
els.forEach(function (el) {
|
|
10
10
|
delete el.location;
|
|
11
|
-
if (types_1.isSelectElement(el) || types_1.isPluralElement(el)) {
|
|
11
|
+
if ((0, types_1.isSelectElement)(el) || (0, types_1.isPluralElement)(el)) {
|
|
12
12
|
for (var k in el.options) {
|
|
13
13
|
delete el.options[k].location;
|
|
14
14
|
pruneLocation(el.options[k].value);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
else if (types_1.isNumberElement(el) && types_1.isNumberSkeleton(el.style)) {
|
|
17
|
+
else if ((0, types_1.isNumberElement)(el) && (0, types_1.isNumberSkeleton)(el.style)) {
|
|
18
18
|
delete el.style.location;
|
|
19
19
|
}
|
|
20
|
-
else if ((types_1.isDateElement(el) || types_1.isTimeElement(el)) &&
|
|
21
|
-
types_1.isDateTimeSkeleton(el.style)) {
|
|
20
|
+
else if (((0, types_1.isDateElement)(el) || (0, types_1.isTimeElement)(el)) &&
|
|
21
|
+
(0, types_1.isDateTimeSkeleton)(el.style)) {
|
|
22
22
|
delete el.style.location;
|
|
23
23
|
}
|
|
24
|
-
else if (types_1.isTagElement(el)) {
|
|
24
|
+
else if ((0, types_1.isTagElement)(el)) {
|
|
25
25
|
pruneLocation(el.children);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function parse(message, opts) {
|
|
30
30
|
if (opts === void 0) { opts = {}; }
|
|
31
|
-
opts = tslib_1.__assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
|
|
31
|
+
opts = (0, tslib_1.__assign)({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
|
|
32
32
|
var result = new parser_1.Parser(message, opts).parse();
|
|
33
33
|
if (result.err) {
|
|
34
34
|
var error = SyntaxError(error_1.ErrorKind[result.err.kind]);
|
|
@@ -44,4 +44,4 @@ function parse(message, opts) {
|
|
|
44
44
|
return result.val;
|
|
45
45
|
}
|
|
46
46
|
exports.parse = parse;
|
|
47
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
47
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
package/lib/manipulator.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isPluralElement, isSelectElement, } from './types';
|
|
|
3
3
|
function cloneDeep(obj) {
|
|
4
4
|
if (Array.isArray(obj)) {
|
|
5
5
|
// @ts-expect-error meh
|
|
6
|
-
return __spreadArray([], obj.map(cloneDeep));
|
|
6
|
+
return __spreadArray([], obj.map(cloneDeep), true);
|
|
7
7
|
}
|
|
8
8
|
if (typeof obj === 'object') {
|
|
9
9
|
// @ts-expect-error meh
|
|
@@ -34,7 +34,7 @@ export function hoistSelectors(ast) {
|
|
|
34
34
|
var cloned = cloneDeep(el);
|
|
35
35
|
var options_1 = cloned.options;
|
|
36
36
|
cloned.options = Object.keys(options_1).reduce(function (all, k) {
|
|
37
|
-
var newValue = hoistSelectors(__spreadArray(__spreadArray(__spreadArray([], ast.slice(0, i)), options_1[k].value), ast.slice(i + 1)));
|
|
37
|
+
var newValue = hoistSelectors(__spreadArray(__spreadArray(__spreadArray([], ast.slice(0, i), true), options_1[k].value, true), ast.slice(i + 1), true));
|
|
38
38
|
all[k] = {
|
|
39
39
|
value: newValue,
|
|
40
40
|
};
|
package/lib/parser.js
CHANGED
|
@@ -4,8 +4,8 @@ import { ErrorKind } from './error';
|
|
|
4
4
|
import { SKELETON_TYPE, TYPE, } from './types';
|
|
5
5
|
import { SPACE_SEPARATOR_REGEX } from './regex.generated';
|
|
6
6
|
import { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';
|
|
7
|
-
var SPACE_SEPARATOR_START_REGEX = new RegExp("^"
|
|
8
|
-
var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source
|
|
7
|
+
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
|
|
8
|
+
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
|
|
9
9
|
function createLocation(start, end) {
|
|
10
10
|
return { start: start, end: end };
|
|
11
11
|
}
|
|
@@ -252,7 +252,7 @@ var Parser = /** @class */ (function () {
|
|
|
252
252
|
return {
|
|
253
253
|
val: {
|
|
254
254
|
type: TYPE.literal,
|
|
255
|
-
value: "<"
|
|
255
|
+
value: "<".concat(tagName, "/>"),
|
|
256
256
|
location: createLocation(startPosition, this.clonePosition()),
|
|
257
257
|
},
|
|
258
258
|
err: null,
|
|
@@ -858,7 +858,7 @@ var Parser = /** @class */ (function () {
|
|
|
858
858
|
}
|
|
859
859
|
var code = codePointAt(this.message, offset);
|
|
860
860
|
if (code === undefined) {
|
|
861
|
-
throw Error("Offset "
|
|
861
|
+
throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
|
|
862
862
|
}
|
|
863
863
|
return code;
|
|
864
864
|
};
|
|
@@ -926,7 +926,7 @@ var Parser = /** @class */ (function () {
|
|
|
926
926
|
*/
|
|
927
927
|
Parser.prototype.bumpTo = function (targetOffset) {
|
|
928
928
|
if (this.offset() > targetOffset) {
|
|
929
|
-
throw Error("targetOffset "
|
|
929
|
+
throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
|
|
930
930
|
}
|
|
931
931
|
targetOffset = Math.min(targetOffset, this.message.length);
|
|
932
932
|
while (true) {
|
|
@@ -935,7 +935,7 @@ var Parser = /** @class */ (function () {
|
|
|
935
935
|
break;
|
|
936
936
|
}
|
|
937
937
|
if (offset > targetOffset) {
|
|
938
|
-
throw Error("targetOffset "
|
|
938
|
+
throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
|
|
939
939
|
}
|
|
940
940
|
this.bump();
|
|
941
941
|
if (this.isEOF()) {
|
package/lib/printer.js
CHANGED
|
@@ -30,7 +30,7 @@ export function doPrintAST(ast, isInPlural) {
|
|
|
30
30
|
return printedNodes.join('');
|
|
31
31
|
}
|
|
32
32
|
function printTagElement(el) {
|
|
33
|
-
return "<"
|
|
33
|
+
return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
|
|
34
34
|
}
|
|
35
35
|
function printEscapedMessage(message) {
|
|
36
36
|
return message.replace(/([{}](?:.*[{}])?)/su, "'$1'");
|
|
@@ -42,26 +42,26 @@ function printLiteralElement(_a, isInPlural) {
|
|
|
42
42
|
}
|
|
43
43
|
function printArgumentElement(_a) {
|
|
44
44
|
var value = _a.value;
|
|
45
|
-
return "{"
|
|
45
|
+
return "{".concat(value, "}");
|
|
46
46
|
}
|
|
47
47
|
function printSimpleFormatElement(el) {
|
|
48
|
-
return "{"
|
|
48
|
+
return "{".concat(el.value, ", ").concat(TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
|
|
49
49
|
}
|
|
50
50
|
function printNumberSkeletonToken(token) {
|
|
51
51
|
var stem = token.stem, options = token.options;
|
|
52
52
|
return options.length === 0
|
|
53
53
|
? stem
|
|
54
|
-
: ""
|
|
54
|
+
: "".concat(stem).concat(options.map(function (o) { return "/".concat(o); }).join(''));
|
|
55
55
|
}
|
|
56
56
|
function printArgumentStyle(style) {
|
|
57
57
|
if (typeof style === 'string') {
|
|
58
58
|
return printEscapedMessage(style);
|
|
59
59
|
}
|
|
60
60
|
else if (style.type === SKELETON_TYPE.dateTime) {
|
|
61
|
-
return "::"
|
|
61
|
+
return "::".concat(printDateTimeSkeleton(style));
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
return "::"
|
|
64
|
+
return "::".concat(style.tokens.map(printNumberSkeletonToken).join(' '));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
export function printDateTimeSkeleton(style) {
|
|
@@ -72,10 +72,10 @@ function printSelectElement(el) {
|
|
|
72
72
|
el.value,
|
|
73
73
|
'select',
|
|
74
74
|
Object.keys(el.options)
|
|
75
|
-
.map(function (id) { return id
|
|
75
|
+
.map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}"); })
|
|
76
76
|
.join(' '),
|
|
77
77
|
].join(',');
|
|
78
|
-
return "{"
|
|
78
|
+
return "{".concat(msg, "}");
|
|
79
79
|
}
|
|
80
80
|
function printPluralElement(el) {
|
|
81
81
|
var type = el.pluralType === 'cardinal' ? 'plural' : 'selectordinal';
|
|
@@ -83,9 +83,9 @@ function printPluralElement(el) {
|
|
|
83
83
|
el.value,
|
|
84
84
|
type,
|
|
85
85
|
__spreadArray([
|
|
86
|
-
el.offset ? "offset:"
|
|
87
|
-
], Object.keys(el.options).map(function (id) { return id
|
|
86
|
+
el.offset ? "offset:".concat(el.offset) : ''
|
|
87
|
+
], Object.keys(el.options).map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}"); }), true).filter(Boolean)
|
|
88
88
|
.join(' '),
|
|
89
89
|
].join(',');
|
|
90
|
-
return "{"
|
|
90
|
+
return "{".concat(msg, "}");
|
|
91
91
|
}
|
package/manipulator.js
CHANGED
|
@@ -6,7 +6,7 @@ var types_1 = require("./types");
|
|
|
6
6
|
function cloneDeep(obj) {
|
|
7
7
|
if (Array.isArray(obj)) {
|
|
8
8
|
// @ts-expect-error meh
|
|
9
|
-
return tslib_1.__spreadArray([], obj.map(cloneDeep));
|
|
9
|
+
return (0, tslib_1.__spreadArray)([], obj.map(cloneDeep), true);
|
|
10
10
|
}
|
|
11
11
|
if (typeof obj === 'object') {
|
|
12
12
|
// @ts-expect-error meh
|
|
@@ -32,12 +32,12 @@ function cloneDeep(obj) {
|
|
|
32
32
|
function hoistSelectors(ast) {
|
|
33
33
|
var _loop_1 = function (i) {
|
|
34
34
|
var el = ast[i];
|
|
35
|
-
if (types_1.isPluralElement(el) || types_1.isSelectElement(el)) {
|
|
35
|
+
if ((0, types_1.isPluralElement)(el) || (0, types_1.isSelectElement)(el)) {
|
|
36
36
|
// pull this out of the ast and move it to the top
|
|
37
37
|
var cloned = cloneDeep(el);
|
|
38
38
|
var options_1 = cloned.options;
|
|
39
39
|
cloned.options = Object.keys(options_1).reduce(function (all, k) {
|
|
40
|
-
var newValue = hoistSelectors(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], ast.slice(0, i)), options_1[k].value), ast.slice(i + 1)));
|
|
40
|
+
var newValue = hoistSelectors((0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], ast.slice(0, i), true), options_1[k].value, true), ast.slice(i + 1), true));
|
|
41
41
|
all[k] = {
|
|
42
42
|
value: newValue,
|
|
43
43
|
};
|
package/no-parser.js
CHANGED
|
@@ -6,4 +6,4 @@ function parse() {
|
|
|
6
6
|
throw new Error("You're trying to format an uncompiled message with react-intl without parser, please import from 'react-int' instead");
|
|
7
7
|
}
|
|
8
8
|
exports.parse = parse;
|
|
9
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/icu-messageformat-parser",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/formatjs/formatjs.git",
|
|
11
|
+
"directory": "packages/icu-messageformat-parser"
|
|
12
|
+
},
|
|
8
13
|
"dependencies": {
|
|
9
|
-
"@formatjs/ecma402-abstract": "1.
|
|
10
|
-
"@formatjs/icu-skeleton-parser": "1.
|
|
14
|
+
"@formatjs/ecma402-abstract": "1.11.1",
|
|
15
|
+
"@formatjs/icu-skeleton-parser": "1.3.3",
|
|
11
16
|
"tslib": "^2.1.0"
|
|
12
17
|
}
|
|
13
18
|
}
|
package/parser.js
CHANGED
|
@@ -7,8 +7,8 @@ var error_1 = require("./error");
|
|
|
7
7
|
var types_1 = require("./types");
|
|
8
8
|
var regex_generated_1 = require("./regex.generated");
|
|
9
9
|
var icu_skeleton_parser_1 = require("@formatjs/icu-skeleton-parser");
|
|
10
|
-
var SPACE_SEPARATOR_START_REGEX = new RegExp("^"
|
|
11
|
-
var SPACE_SEPARATOR_END_REGEX = new RegExp(regex_generated_1.SPACE_SEPARATOR_REGEX.source
|
|
10
|
+
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*"));
|
|
11
|
+
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*$"));
|
|
12
12
|
function createLocation(start, end) {
|
|
13
13
|
return { start: start, end: end };
|
|
14
14
|
}
|
|
@@ -255,7 +255,7 @@ var Parser = /** @class */ (function () {
|
|
|
255
255
|
return {
|
|
256
256
|
val: {
|
|
257
257
|
type: types_1.TYPE.literal,
|
|
258
|
-
value: "<"
|
|
258
|
+
value: "<".concat(tagName, "/>"),
|
|
259
259
|
location: createLocation(startPosition, this.clonePosition()),
|
|
260
260
|
},
|
|
261
261
|
err: null,
|
|
@@ -545,7 +545,7 @@ var Parser = /** @class */ (function () {
|
|
|
545
545
|
pattern: skeleton,
|
|
546
546
|
location: styleAndLocation.styleLocation,
|
|
547
547
|
parsedOptions: this.shouldParseSkeletons
|
|
548
|
-
? icu_skeleton_parser_1.parseDateTimeSkeleton(skeleton)
|
|
548
|
+
? (0, icu_skeleton_parser_1.parseDateTimeSkeleton)(skeleton)
|
|
549
549
|
: {},
|
|
550
550
|
};
|
|
551
551
|
var type = argType === 'date' ? types_1.TYPE.date : types_1.TYPE.time;
|
|
@@ -579,7 +579,7 @@ var Parser = /** @class */ (function () {
|
|
|
579
579
|
var typeEndPosition_1 = this.clonePosition();
|
|
580
580
|
this.bumpSpace();
|
|
581
581
|
if (!this.bumpIf(',')) {
|
|
582
|
-
return this.error(error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, tslib_1.__assign({}, typeEndPosition_1)));
|
|
582
|
+
return this.error(error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, (0, tslib_1.__assign)({}, typeEndPosition_1)));
|
|
583
583
|
}
|
|
584
584
|
this.bumpSpace();
|
|
585
585
|
// Parse offset:
|
|
@@ -703,7 +703,7 @@ var Parser = /** @class */ (function () {
|
|
|
703
703
|
Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
|
|
704
704
|
var tokens = [];
|
|
705
705
|
try {
|
|
706
|
-
tokens = icu_skeleton_parser_1.parseNumberSkeletonFromString(skeleton);
|
|
706
|
+
tokens = (0, icu_skeleton_parser_1.parseNumberSkeletonFromString)(skeleton);
|
|
707
707
|
}
|
|
708
708
|
catch (e) {
|
|
709
709
|
return this.error(error_1.ErrorKind.INVALID_NUMBER_SKELETON, location);
|
|
@@ -714,7 +714,7 @@ var Parser = /** @class */ (function () {
|
|
|
714
714
|
tokens: tokens,
|
|
715
715
|
location: location,
|
|
716
716
|
parsedOptions: this.shouldParseSkeletons
|
|
717
|
-
? icu_skeleton_parser_1.parseNumberSkeleton(tokens)
|
|
717
|
+
? (0, icu_skeleton_parser_1.parseNumberSkeleton)(tokens)
|
|
718
718
|
: {},
|
|
719
719
|
},
|
|
720
720
|
err: null,
|
|
@@ -861,7 +861,7 @@ var Parser = /** @class */ (function () {
|
|
|
861
861
|
}
|
|
862
862
|
var code = codePointAt(this.message, offset);
|
|
863
863
|
if (code === undefined) {
|
|
864
|
-
throw Error("Offset "
|
|
864
|
+
throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
|
|
865
865
|
}
|
|
866
866
|
return code;
|
|
867
867
|
};
|
|
@@ -929,7 +929,7 @@ var Parser = /** @class */ (function () {
|
|
|
929
929
|
*/
|
|
930
930
|
Parser.prototype.bumpTo = function (targetOffset) {
|
|
931
931
|
if (this.offset() > targetOffset) {
|
|
932
|
-
throw Error("targetOffset "
|
|
932
|
+
throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
|
|
933
933
|
}
|
|
934
934
|
targetOffset = Math.min(targetOffset, this.message.length);
|
|
935
935
|
while (true) {
|
|
@@ -938,7 +938,7 @@ var Parser = /** @class */ (function () {
|
|
|
938
938
|
break;
|
|
939
939
|
}
|
|
940
940
|
if (offset > targetOffset) {
|
|
941
|
-
throw Error("targetOffset "
|
|
941
|
+
throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
|
|
942
942
|
}
|
|
943
943
|
this.bump();
|
|
944
944
|
if (this.isEOF()) {
|
package/printer.js
CHANGED
|
@@ -9,25 +9,25 @@ function printAST(ast) {
|
|
|
9
9
|
exports.printAST = printAST;
|
|
10
10
|
function doPrintAST(ast, isInPlural) {
|
|
11
11
|
var printedNodes = ast.map(function (el) {
|
|
12
|
-
if (types_1.isLiteralElement(el)) {
|
|
12
|
+
if ((0, types_1.isLiteralElement)(el)) {
|
|
13
13
|
return printLiteralElement(el, isInPlural);
|
|
14
14
|
}
|
|
15
|
-
if (types_1.isArgumentElement(el)) {
|
|
15
|
+
if ((0, types_1.isArgumentElement)(el)) {
|
|
16
16
|
return printArgumentElement(el);
|
|
17
17
|
}
|
|
18
|
-
if (types_1.isDateElement(el) || types_1.isTimeElement(el) || types_1.isNumberElement(el)) {
|
|
18
|
+
if ((0, types_1.isDateElement)(el) || (0, types_1.isTimeElement)(el) || (0, types_1.isNumberElement)(el)) {
|
|
19
19
|
return printSimpleFormatElement(el);
|
|
20
20
|
}
|
|
21
|
-
if (types_1.isPluralElement(el)) {
|
|
21
|
+
if ((0, types_1.isPluralElement)(el)) {
|
|
22
22
|
return printPluralElement(el);
|
|
23
23
|
}
|
|
24
|
-
if (types_1.isSelectElement(el)) {
|
|
24
|
+
if ((0, types_1.isSelectElement)(el)) {
|
|
25
25
|
return printSelectElement(el);
|
|
26
26
|
}
|
|
27
|
-
if (types_1.isPoundElement(el)) {
|
|
27
|
+
if ((0, types_1.isPoundElement)(el)) {
|
|
28
28
|
return '#';
|
|
29
29
|
}
|
|
30
|
-
if (types_1.isTagElement(el)) {
|
|
30
|
+
if ((0, types_1.isTagElement)(el)) {
|
|
31
31
|
return printTagElement(el);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -35,7 +35,7 @@ function doPrintAST(ast, isInPlural) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.doPrintAST = doPrintAST;
|
|
37
37
|
function printTagElement(el) {
|
|
38
|
-
return "<"
|
|
38
|
+
return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
|
|
39
39
|
}
|
|
40
40
|
function printEscapedMessage(message) {
|
|
41
41
|
return message.replace(/([{}](?:.*[{}])?)/su, "'$1'");
|
|
@@ -47,26 +47,26 @@ function printLiteralElement(_a, isInPlural) {
|
|
|
47
47
|
}
|
|
48
48
|
function printArgumentElement(_a) {
|
|
49
49
|
var value = _a.value;
|
|
50
|
-
return "{"
|
|
50
|
+
return "{".concat(value, "}");
|
|
51
51
|
}
|
|
52
52
|
function printSimpleFormatElement(el) {
|
|
53
|
-
return "{"
|
|
53
|
+
return "{".concat(el.value, ", ").concat(types_1.TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
|
|
54
54
|
}
|
|
55
55
|
function printNumberSkeletonToken(token) {
|
|
56
56
|
var stem = token.stem, options = token.options;
|
|
57
57
|
return options.length === 0
|
|
58
58
|
? stem
|
|
59
|
-
: ""
|
|
59
|
+
: "".concat(stem).concat(options.map(function (o) { return "/".concat(o); }).join(''));
|
|
60
60
|
}
|
|
61
61
|
function printArgumentStyle(style) {
|
|
62
62
|
if (typeof style === 'string') {
|
|
63
63
|
return printEscapedMessage(style);
|
|
64
64
|
}
|
|
65
65
|
else if (style.type === types_1.SKELETON_TYPE.dateTime) {
|
|
66
|
-
return "::"
|
|
66
|
+
return "::".concat(printDateTimeSkeleton(style));
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
return "::"
|
|
69
|
+
return "::".concat(style.tokens.map(printNumberSkeletonToken).join(' '));
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
function printDateTimeSkeleton(style) {
|
|
@@ -78,20 +78,20 @@ function printSelectElement(el) {
|
|
|
78
78
|
el.value,
|
|
79
79
|
'select',
|
|
80
80
|
Object.keys(el.options)
|
|
81
|
-
.map(function (id) { return id
|
|
81
|
+
.map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}"); })
|
|
82
82
|
.join(' '),
|
|
83
83
|
].join(',');
|
|
84
|
-
return "{"
|
|
84
|
+
return "{".concat(msg, "}");
|
|
85
85
|
}
|
|
86
86
|
function printPluralElement(el) {
|
|
87
87
|
var type = el.pluralType === 'cardinal' ? 'plural' : 'selectordinal';
|
|
88
88
|
var msg = [
|
|
89
89
|
el.value,
|
|
90
90
|
type,
|
|
91
|
-
tslib_1.__spreadArray([
|
|
92
|
-
el.offset ? "offset:"
|
|
93
|
-
], Object.keys(el.options).map(function (id) { return id
|
|
91
|
+
(0, tslib_1.__spreadArray)([
|
|
92
|
+
el.offset ? "offset:".concat(el.offset) : ''
|
|
93
|
+
], Object.keys(el.options).map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}"); }), true).filter(Boolean)
|
|
94
94
|
.join(' '),
|
|
95
95
|
].join(',');
|
|
96
|
-
return "{"
|
|
96
|
+
return "{".concat(msg, "}");
|
|
97
97
|
}
|