@formatjs/cli 5.1.12 → 6.0.0
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/bin/formatjs +54 -49
- package/package.json +2 -2
package/bin/formatjs
CHANGED
|
@@ -159145,6 +159145,19 @@ var init_extract = __esm({
|
|
|
159145
159145
|
});
|
|
159146
159146
|
|
|
159147
159147
|
// ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/cli-lib/lib_esnext/src/pseudo_locale.js
|
|
159148
|
+
function forEachLiteralElement(ast, fn) {
|
|
159149
|
+
ast.forEach((el) => {
|
|
159150
|
+
if ((0, import_icu_messageformat_parser2.isLiteralElement)(el)) {
|
|
159151
|
+
fn(el);
|
|
159152
|
+
} else if ((0, import_icu_messageformat_parser2.isPluralElement)(el) || (0, import_icu_messageformat_parser2.isSelectElement)(el)) {
|
|
159153
|
+
for (const opt of Object.values(el.options)) {
|
|
159154
|
+
forEachLiteralElement(opt.value, fn);
|
|
159155
|
+
}
|
|
159156
|
+
} else if ((0, import_icu_messageformat_parser2.isTagElement)(el)) {
|
|
159157
|
+
forEachLiteralElement(el.children, fn);
|
|
159158
|
+
}
|
|
159159
|
+
});
|
|
159160
|
+
}
|
|
159148
159161
|
function generateXXLS(msg) {
|
|
159149
159162
|
const ast = typeof msg === "string" ? (0, import_icu_messageformat_parser2.parse)(msg) : msg;
|
|
159150
159163
|
const lastChunk = ast[ast.length - 1];
|
|
@@ -159156,16 +159169,8 @@ function generateXXLS(msg) {
|
|
|
159156
159169
|
}
|
|
159157
159170
|
function generateXXAC(msg) {
|
|
159158
159171
|
const ast = typeof msg === "string" ? (0, import_icu_messageformat_parser2.parse)(msg) : msg;
|
|
159159
|
-
ast
|
|
159160
|
-
|
|
159161
|
-
el.value = el.value.toUpperCase();
|
|
159162
|
-
} else if ((0, import_icu_messageformat_parser2.isPluralElement)(el) || (0, import_icu_messageformat_parser2.isSelectElement)(el)) {
|
|
159163
|
-
for (const opt of Object.values(el.options)) {
|
|
159164
|
-
generateXXAC(opt.value);
|
|
159165
|
-
}
|
|
159166
|
-
} else if ((0, import_icu_messageformat_parser2.isTagElement)(el)) {
|
|
159167
|
-
generateXXAC(el.children);
|
|
159168
|
-
}
|
|
159172
|
+
forEachLiteralElement(ast, (el) => {
|
|
159173
|
+
el.value = el.value.toUpperCase();
|
|
159169
159174
|
});
|
|
159170
159175
|
return ast;
|
|
159171
159176
|
}
|
|
@@ -159178,57 +159183,57 @@ function generateXXHA(msg) {
|
|
|
159178
159183
|
}
|
|
159179
159184
|
return [{ type: import_icu_messageformat_parser2.TYPE.literal, value: "[javascript]" }, ...ast];
|
|
159180
159185
|
}
|
|
159186
|
+
function transformString(map, elongate = false, msg) {
|
|
159187
|
+
return msg.replace(/[a-z]/gi, (ch) => {
|
|
159188
|
+
const cc = ch.charCodeAt(0);
|
|
159189
|
+
if (cc >= 97 && cc <= 122) {
|
|
159190
|
+
const newChar = String.fromCodePoint(map.small[cc - 97]);
|
|
159191
|
+
if (elongate && (cc === 97 || cc === 101 || cc === 111 || cc === 117)) {
|
|
159192
|
+
return newChar + newChar;
|
|
159193
|
+
}
|
|
159194
|
+
return newChar;
|
|
159195
|
+
}
|
|
159196
|
+
if (cc >= 65 && cc <= 90) {
|
|
159197
|
+
return String.fromCodePoint(map.caps[cc - 65]);
|
|
159198
|
+
}
|
|
159199
|
+
return ch;
|
|
159200
|
+
});
|
|
159201
|
+
}
|
|
159181
159202
|
function generateENXA(msg) {
|
|
159182
159203
|
const ast = typeof msg === "string" ? (0, import_icu_messageformat_parser2.parse)(msg) : msg;
|
|
159183
|
-
ast
|
|
159184
|
-
|
|
159185
|
-
el.value = el.value.split("").map((c) => {
|
|
159186
|
-
const i = ASCII.indexOf(c);
|
|
159187
|
-
if (i < 0) {
|
|
159188
|
-
return c;
|
|
159189
|
-
}
|
|
159190
|
-
return ACCENTED_ASCII[i];
|
|
159191
|
-
}).join("");
|
|
159192
|
-
} else if ((0, import_icu_messageformat_parser2.isPluralElement)(el) || (0, import_icu_messageformat_parser2.isSelectElement)(el)) {
|
|
159193
|
-
for (const opt of Object.values(el.options)) {
|
|
159194
|
-
generateENXA(opt.value);
|
|
159195
|
-
}
|
|
159196
|
-
} else if ((0, import_icu_messageformat_parser2.isTagElement)(el)) {
|
|
159197
|
-
generateENXA(el.children);
|
|
159198
|
-
}
|
|
159204
|
+
forEachLiteralElement(ast, (el) => {
|
|
159205
|
+
el.value = transformString(ACCENTED_MAP, true, el.value);
|
|
159199
159206
|
});
|
|
159200
|
-
return
|
|
159207
|
+
return [
|
|
159208
|
+
{ type: import_icu_messageformat_parser2.TYPE.literal, value: "[" },
|
|
159209
|
+
...ast,
|
|
159210
|
+
{ type: import_icu_messageformat_parser2.TYPE.literal, value: "]" }
|
|
159211
|
+
];
|
|
159201
159212
|
}
|
|
159202
159213
|
function generateENXB(msg) {
|
|
159203
159214
|
const ast = typeof msg === "string" ? (0, import_icu_messageformat_parser2.parse)(msg) : msg;
|
|
159204
|
-
ast
|
|
159205
|
-
|
|
159206
|
-
const pseudoString = el.value.split("").map((c, index) => {
|
|
159207
|
-
const i = ASCII.indexOf(c);
|
|
159208
|
-
const canPad = (index + 1) % 3 === 0;
|
|
159209
|
-
if (i < 0) {
|
|
159210
|
-
return c;
|
|
159211
|
-
}
|
|
159212
|
-
return canPad ? ACCENTED_ASCII[i].repeat(3) : ACCENTED_ASCII[i];
|
|
159213
|
-
}).join("");
|
|
159214
|
-
el.value = `[!! ${pseudoString} !!]`;
|
|
159215
|
-
} else if ((0, import_icu_messageformat_parser2.isPluralElement)(el) || (0, import_icu_messageformat_parser2.isSelectElement)(el)) {
|
|
159216
|
-
for (const opt of Object.values(el.options)) {
|
|
159217
|
-
generateENXB(opt.value);
|
|
159218
|
-
}
|
|
159219
|
-
} else if ((0, import_icu_messageformat_parser2.isTagElement)(el)) {
|
|
159220
|
-
generateENXB(el.children);
|
|
159221
|
-
}
|
|
159215
|
+
forEachLiteralElement(ast, (el) => {
|
|
159216
|
+
el.value = transformString(FLIPPED_MAP, false, el.value);
|
|
159222
159217
|
});
|
|
159223
|
-
return
|
|
159218
|
+
return [
|
|
159219
|
+
{ type: import_icu_messageformat_parser2.TYPE.literal, value: "\u202E" },
|
|
159220
|
+
...ast,
|
|
159221
|
+
{ type: import_icu_messageformat_parser2.TYPE.literal, value: "\u202C" }
|
|
159222
|
+
];
|
|
159224
159223
|
}
|
|
159225
|
-
var import_icu_messageformat_parser2,
|
|
159224
|
+
var import_icu_messageformat_parser2, ACCENTED_MAP, FLIPPED_MAP;
|
|
159226
159225
|
var init_pseudo_locale = __esm({
|
|
159227
159226
|
"../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/cli-lib/lib_esnext/src/pseudo_locale.js"() {
|
|
159228
159227
|
"use strict";
|
|
159229
159228
|
import_icu_messageformat_parser2 = __toESM(require_icu_messageformat_parser());
|
|
159230
|
-
|
|
159231
|
-
|
|
159229
|
+
ACCENTED_MAP = {
|
|
159230
|
+
"caps": [550, 385, 391, 7698, 7702, 401, 403, 294, 298, 308, 310, 319, 7742, 544, 510, 420, 586, 344, 350, 358, 364, 7804, 7814, 7818, 7822, 7824],
|
|
159231
|
+
"small": [551, 384, 392, 7699, 7703, 402, 608, 295, 299, 309, 311, 320, 7743, 414, 511, 421, 587, 345, 351, 359, 365, 7805, 7815, 7819, 7823, 7825]
|
|
159232
|
+
};
|
|
159233
|
+
FLIPPED_MAP = {
|
|
159234
|
+
"caps": [8704, 1296, 8579, 5601, 398, 8498, 8513, 72, 73, 383, 1276, 8514, 87, 78, 79, 1280, 210, 7450, 83, 8869, 8745, 581, 77, 88, 8516, 90],
|
|
159235
|
+
"small": [592, 113, 596, 112, 477, 607, 387, 613, 305, 638, 670, 645, 623, 117, 111, 100, 98, 633, 115, 647, 110, 652, 653, 120, 654, 122]
|
|
159236
|
+
};
|
|
159232
159237
|
}
|
|
159233
159238
|
});
|
|
159234
159239
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "A CLI for formatjs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"url": "https://github.com/formatjs/formatjs/issues"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@formatjs/cli-lib": "
|
|
36
|
+
"@formatjs/cli-lib": "6.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@vue/compiler-sfc": "^3.2.34"
|