@intlify/core 9.3.0-beta.1 → 9.3.0-beta.11

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.
@@ -0,0 +1,1709 @@
1
+ /*!
2
+ * core v9.3.0-beta.11
3
+ * (c) 2022 kazuya kawaguchi
4
+ * Released under the MIT License.
5
+ */
6
+ /**
7
+ * Original Utilities
8
+ * written by kazuya kawaguchi
9
+ */
10
+ const inBrowser = typeof window !== 'undefined';
11
+ let mark;
12
+ let measure;
13
+ {
14
+ const perf = inBrowser && window.performance;
15
+ if (perf &&
16
+ perf.mark &&
17
+ perf.measure &&
18
+ perf.clearMarks &&
19
+ // @ts-ignore browser compat
20
+ perf.clearMeasures) {
21
+ mark = (tag) => {
22
+ perf.mark(tag);
23
+ };
24
+ measure = (name, startTag, endTag) => {
25
+ perf.measure(name, startTag, endTag);
26
+ perf.clearMarks(startTag);
27
+ perf.clearMarks(endTag);
28
+ };
29
+ }
30
+ }
31
+ const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g;
32
+ /* eslint-disable */
33
+ function format(message, ...args) {
34
+ if (args.length === 1 && isObject(args[0])) {
35
+ args = args[0];
36
+ }
37
+ if (!args || !args.hasOwnProperty) {
38
+ args = {};
39
+ }
40
+ return message.replace(RE_ARGS, (match, identifier) => {
41
+ return args.hasOwnProperty(identifier) ? args[identifier] : '';
42
+ });
43
+ }
44
+ const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source });
45
+ const friendlyJSONstringify = (json) => JSON.stringify(json)
46
+ .replace(/\u2028/g, '\\u2028')
47
+ .replace(/\u2029/g, '\\u2029')
48
+ .replace(/\u0027/g, '\\u0027');
49
+ const isNumber = (val) => typeof val === 'number' && isFinite(val);
50
+ const isDate = (val) => toTypeString(val) === '[object Date]';
51
+ const isRegExp = (val) => toTypeString(val) === '[object RegExp]';
52
+ const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0;
53
+ function warn(msg, err) {
54
+ if (typeof console !== 'undefined') {
55
+ console.warn(`[intlify] ` + msg);
56
+ /* istanbul ignore if */
57
+ if (err) {
58
+ console.warn(err.stack);
59
+ }
60
+ }
61
+ }
62
+ const assign = Object.assign;
63
+ function escapeHtml(rawText) {
64
+ return rawText
65
+ .replace(/</g, '&lt;')
66
+ .replace(/>/g, '&gt;')
67
+ .replace(/"/g, '&quot;')
68
+ .replace(/'/g, '&apos;');
69
+ }
70
+ /* eslint-enable */
71
+ /**
72
+ * Useful Utilities By Evan you
73
+ * Modified by kazuya kawaguchi
74
+ * MIT License
75
+ * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts
76
+ * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts
77
+ */
78
+ const isArray = Array.isArray;
79
+ const isFunction = (val) => typeof val === 'function';
80
+ const isString = (val) => typeof val === 'string';
81
+ const isBoolean = (val) => typeof val === 'boolean';
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ const isObject = (val) => val !== null && typeof val === 'object';
84
+ const objectToString = Object.prototype.toString;
85
+ const toTypeString = (value) => objectToString.call(value);
86
+ const isPlainObject = (val) => toTypeString(val) === '[object Object]';
87
+ // for converting list and named values to displayed strings.
88
+ const toDisplayString = (val) => {
89
+ return val == null
90
+ ? ''
91
+ : isArray(val) || (isPlainObject(val) && val.toString === objectToString)
92
+ ? JSON.stringify(val, null, 2)
93
+ : String(val);
94
+ };
95
+ const RANGE = 2;
96
+ function generateCodeFrame(source, start = 0, end = source.length) {
97
+ const lines = source.split(/\r?\n/);
98
+ let count = 0;
99
+ const res = [];
100
+ for (let i = 0; i < lines.length; i++) {
101
+ count += lines[i].length + 1;
102
+ if (count >= start) {
103
+ for (let j = i - RANGE; j <= i + RANGE || end > count; j++) {
104
+ if (j < 0 || j >= lines.length)
105
+ continue;
106
+ const line = j + 1;
107
+ res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`);
108
+ const lineLength = lines[j].length;
109
+ if (j === i) {
110
+ // push underline
111
+ const pad = start - (count - lineLength) + 1;
112
+ const length = Math.max(1, end > count ? lineLength - pad : end - start);
113
+ res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
114
+ }
115
+ else if (j > i) {
116
+ if (end > count) {
117
+ const length = Math.max(Math.min(end - count, lineLength), 1);
118
+ res.push(` | ` + '^'.repeat(length));
119
+ }
120
+ count += lineLength + 1;
121
+ }
122
+ }
123
+ break;
124
+ }
125
+ }
126
+ return res.join('\n');
127
+ }
128
+
129
+ const CompileErrorCodes = {
130
+ // tokenizer error codes
131
+ EXPECTED_TOKEN: 1,
132
+ INVALID_TOKEN_IN_PLACEHOLDER: 2,
133
+ UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
134
+ UNKNOWN_ESCAPE_SEQUENCE: 4,
135
+ INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
136
+ UNBALANCED_CLOSING_BRACE: 6,
137
+ UNTERMINATED_CLOSING_BRACE: 7,
138
+ EMPTY_PLACEHOLDER: 8,
139
+ NOT_ALLOW_NEST_PLACEHOLDER: 9,
140
+ INVALID_LINKED_FORMAT: 10,
141
+ // parser error codes
142
+ MUST_HAVE_MESSAGES_IN_PLURAL: 11,
143
+ UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
144
+ UNEXPECTED_EMPTY_LINKED_KEY: 13,
145
+ UNEXPECTED_LEXICAL_ANALYSIS: 14,
146
+ // Special value for higher-order compilers to pick up the last code
147
+ // to avoid collision of error codes. This should always be kept as the last
148
+ // item.
149
+ __EXTEND_POINT__: 15
150
+ };
151
+ /** @internal */
152
+ const errorMessages$1 = {
153
+ // tokenizer error messages
154
+ [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`,
155
+ [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`,
156
+ [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`,
157
+ [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`,
158
+ [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`,
159
+ [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`,
160
+ [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`,
161
+ [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`,
162
+ [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`,
163
+ [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`,
164
+ // parser error messages
165
+ [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`,
166
+ [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`,
167
+ [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`,
168
+ [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`
169
+ };
170
+ function createCompileError(code, loc, options = {}) {
171
+ const { domain, messages, args } = options;
172
+ const msg = format((messages || errorMessages$1)[code] || '', ...(args || []))
173
+ ;
174
+ const error = new SyntaxError(String(msg));
175
+ error.code = code;
176
+ if (loc) {
177
+ error.location = loc;
178
+ }
179
+ error.domain = domain;
180
+ return error;
181
+ }
182
+
183
+ const pathStateMachine = [];
184
+ pathStateMachine[0 /* States.BEFORE_PATH */] = {
185
+ ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */],
186
+ ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
187
+ ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */],
188
+ ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */]
189
+ };
190
+ pathStateMachine[1 /* States.IN_PATH */] = {
191
+ ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */],
192
+ ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */],
193
+ ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */],
194
+ ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */]
195
+ };
196
+ pathStateMachine[2 /* States.BEFORE_IDENT */] = {
197
+ ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */],
198
+ ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
199
+ ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */]
200
+ };
201
+ pathStateMachine[3 /* States.IN_IDENT */] = {
202
+ ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
203
+ ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
204
+ ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */],
205
+ ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */],
206
+ ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */],
207
+ ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */]
208
+ };
209
+ pathStateMachine[4 /* States.IN_SUB_PATH */] = {
210
+ ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */],
211
+ ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */],
212
+ ["[" /* PathCharTypes.LEFT_BRACKET */]: [
213
+ 4 /* States.IN_SUB_PATH */,
214
+ 2 /* Actions.INC_SUB_PATH_DEPTH */
215
+ ],
216
+ ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */],
217
+ ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
218
+ ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */]
219
+ };
220
+ pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = {
221
+ ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */],
222
+ ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
223
+ ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */]
224
+ };
225
+ pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = {
226
+ ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */],
227
+ ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
228
+ ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */]
229
+ };
230
+ /**
231
+ * Check if an expression is a literal value.
232
+ */
233
+ const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
234
+ function isLiteral(exp) {
235
+ return literalValueRE.test(exp);
236
+ }
237
+ /**
238
+ * Strip quotes from a string
239
+ */
240
+ function stripQuotes(str) {
241
+ const a = str.charCodeAt(0);
242
+ const b = str.charCodeAt(str.length - 1);
243
+ return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;
244
+ }
245
+ /**
246
+ * Determine the type of a character in a keypath.
247
+ */
248
+ function getPathCharType(ch) {
249
+ if (ch === undefined || ch === null) {
250
+ return "o" /* PathCharTypes.END_OF_FAIL */;
251
+ }
252
+ const code = ch.charCodeAt(0);
253
+ switch (code) {
254
+ case 0x5b: // [
255
+ case 0x5d: // ]
256
+ case 0x2e: // .
257
+ case 0x22: // "
258
+ case 0x27: // '
259
+ return ch;
260
+ case 0x5f: // _
261
+ case 0x24: // $
262
+ case 0x2d: // -
263
+ return "i" /* PathCharTypes.IDENT */;
264
+ case 0x09: // Tab (HT)
265
+ case 0x0a: // Newline (LF)
266
+ case 0x0d: // Return (CR)
267
+ case 0xa0: // No-break space (NBSP)
268
+ case 0xfeff: // Byte Order Mark (BOM)
269
+ case 0x2028: // Line Separator (LS)
270
+ case 0x2029: // Paragraph Separator (PS)
271
+ return "w" /* PathCharTypes.WORKSPACE */;
272
+ }
273
+ return "i" /* PathCharTypes.IDENT */;
274
+ }
275
+ /**
276
+ * Format a subPath, return its plain form if it is
277
+ * a literal string or number. Otherwise prepend the
278
+ * dynamic indicator (*).
279
+ */
280
+ function formatSubPath(path) {
281
+ const trimmed = path.trim();
282
+ // invalid leading 0
283
+ if (path.charAt(0) === '0' && isNaN(parseInt(path))) {
284
+ return false;
285
+ }
286
+ return isLiteral(trimmed)
287
+ ? stripQuotes(trimmed)
288
+ : "*" /* PathCharTypes.ASTARISK */ + trimmed;
289
+ }
290
+ /**
291
+ * Parse a string path into an array of segments
292
+ */
293
+ function parse(path) {
294
+ const keys = [];
295
+ let index = -1;
296
+ let mode = 0 /* States.BEFORE_PATH */;
297
+ let subPathDepth = 0;
298
+ let c;
299
+ let key; // eslint-disable-line
300
+ let newChar;
301
+ let type;
302
+ let transition;
303
+ let action;
304
+ let typeMap;
305
+ const actions = [];
306
+ actions[0 /* Actions.APPEND */] = () => {
307
+ if (key === undefined) {
308
+ key = newChar;
309
+ }
310
+ else {
311
+ key += newChar;
312
+ }
313
+ };
314
+ actions[1 /* Actions.PUSH */] = () => {
315
+ if (key !== undefined) {
316
+ keys.push(key);
317
+ key = undefined;
318
+ }
319
+ };
320
+ actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => {
321
+ actions[0 /* Actions.APPEND */]();
322
+ subPathDepth++;
323
+ };
324
+ actions[3 /* Actions.PUSH_SUB_PATH */] = () => {
325
+ if (subPathDepth > 0) {
326
+ subPathDepth--;
327
+ mode = 4 /* States.IN_SUB_PATH */;
328
+ actions[0 /* Actions.APPEND */]();
329
+ }
330
+ else {
331
+ subPathDepth = 0;
332
+ if (key === undefined) {
333
+ return false;
334
+ }
335
+ key = formatSubPath(key);
336
+ if (key === false) {
337
+ return false;
338
+ }
339
+ else {
340
+ actions[1 /* Actions.PUSH */]();
341
+ }
342
+ }
343
+ };
344
+ function maybeUnescapeQuote() {
345
+ const nextChar = path[index + 1];
346
+ if ((mode === 5 /* States.IN_SINGLE_QUOTE */ &&
347
+ nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) ||
348
+ (mode === 6 /* States.IN_DOUBLE_QUOTE */ &&
349
+ nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) {
350
+ index++;
351
+ newChar = '\\' + nextChar;
352
+ actions[0 /* Actions.APPEND */]();
353
+ return true;
354
+ }
355
+ }
356
+ while (mode !== null) {
357
+ index++;
358
+ c = path[index];
359
+ if (c === '\\' && maybeUnescapeQuote()) {
360
+ continue;
361
+ }
362
+ type = getPathCharType(c);
363
+ typeMap = pathStateMachine[mode];
364
+ transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */;
365
+ // check parse error
366
+ if (transition === 8 /* States.ERROR */) {
367
+ return;
368
+ }
369
+ mode = transition[0];
370
+ if (transition[1] !== undefined) {
371
+ action = actions[transition[1]];
372
+ if (action) {
373
+ newChar = c;
374
+ if (action() === false) {
375
+ return;
376
+ }
377
+ }
378
+ }
379
+ // check parse finish
380
+ if (mode === 7 /* States.AFTER_PATH */) {
381
+ return keys;
382
+ }
383
+ }
384
+ }
385
+ // path token cache
386
+ const cache = new Map();
387
+ /**
388
+ * key-value message resolver
389
+ *
390
+ * @remarks
391
+ * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved
392
+ *
393
+ * @param obj - A target object to be resolved with path
394
+ * @param path - A {@link Path | path} to resolve the value of message
395
+ *
396
+ * @returns A resolved {@link PathValue | path value}
397
+ *
398
+ * @VueI18nGeneral
399
+ */
400
+ function resolveWithKeyValue(obj, path) {
401
+ return isObject(obj) ? obj[path] : null;
402
+ }
403
+ /**
404
+ * message resolver
405
+ *
406
+ * @remarks
407
+ * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default.
408
+ *
409
+ * @param obj - A target object to be resolved with path
410
+ * @param path - A {@link Path | path} to resolve the value of message
411
+ *
412
+ * @returns A resolved {@link PathValue | path value}
413
+ *
414
+ * @VueI18nGeneral
415
+ */
416
+ function resolveValue(obj, path) {
417
+ // check object
418
+ if (!isObject(obj)) {
419
+ return null;
420
+ }
421
+ // parse path
422
+ let hit = cache.get(path);
423
+ if (!hit) {
424
+ hit = parse(path);
425
+ if (hit) {
426
+ cache.set(path, hit);
427
+ }
428
+ }
429
+ // check hit
430
+ if (!hit) {
431
+ return null;
432
+ }
433
+ // resolve path value
434
+ const len = hit.length;
435
+ let last = obj;
436
+ let i = 0;
437
+ while (i < len) {
438
+ const val = last[hit[i]];
439
+ if (val === undefined) {
440
+ return null;
441
+ }
442
+ last = val;
443
+ i++;
444
+ }
445
+ return last;
446
+ }
447
+
448
+ const DEFAULT_MODIFIER = (str) => str;
449
+ const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line
450
+ const DEFAULT_MESSAGE_DATA_TYPE = 'text';
451
+ const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : values.join('');
452
+ const DEFAULT_INTERPOLATE = toDisplayString;
453
+ function pluralDefault(choice, choicesLength) {
454
+ choice = Math.abs(choice);
455
+ if (choicesLength === 2) {
456
+ // prettier-ignore
457
+ return choice
458
+ ? choice > 1
459
+ ? 1
460
+ : 0
461
+ : 1;
462
+ }
463
+ return choice ? Math.min(choice, 2) : 0;
464
+ }
465
+ function getPluralIndex(options) {
466
+ // prettier-ignore
467
+ const index = isNumber(options.pluralIndex)
468
+ ? options.pluralIndex
469
+ : -1;
470
+ // prettier-ignore
471
+ return options.named && (isNumber(options.named.count) || isNumber(options.named.n))
472
+ ? isNumber(options.named.count)
473
+ ? options.named.count
474
+ : isNumber(options.named.n)
475
+ ? options.named.n
476
+ : index
477
+ : index;
478
+ }
479
+ function normalizeNamed(pluralIndex, props) {
480
+ if (!props.count) {
481
+ props.count = pluralIndex;
482
+ }
483
+ if (!props.n) {
484
+ props.n = pluralIndex;
485
+ }
486
+ }
487
+ function createMessageContext(options = {}) {
488
+ const locale = options.locale;
489
+ const pluralIndex = getPluralIndex(options);
490
+ const pluralRule = isObject(options.pluralRules) &&
491
+ isString(locale) &&
492
+ isFunction(options.pluralRules[locale])
493
+ ? options.pluralRules[locale]
494
+ : pluralDefault;
495
+ const orgPluralRule = isObject(options.pluralRules) &&
496
+ isString(locale) &&
497
+ isFunction(options.pluralRules[locale])
498
+ ? pluralDefault
499
+ : undefined;
500
+ const plural = (messages) => {
501
+ return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)];
502
+ };
503
+ const _list = options.list || [];
504
+ const list = (index) => _list[index];
505
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
506
+ const _named = options.named || {};
507
+ isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
508
+ const named = (key) => _named[key];
509
+ function message(key) {
510
+ // prettier-ignore
511
+ const msg = isFunction(options.messages)
512
+ ? options.messages(key)
513
+ : isObject(options.messages)
514
+ ? options.messages[key]
515
+ : false;
516
+ return !msg
517
+ ? options.parent
518
+ ? options.parent.message(key) // resolve from parent messages
519
+ : DEFAULT_MESSAGE
520
+ : msg;
521
+ }
522
+ const _modifier = (name) => options.modifiers
523
+ ? options.modifiers[name]
524
+ : DEFAULT_MODIFIER;
525
+ const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize)
526
+ ? options.processor.normalize
527
+ : DEFAULT_NORMALIZE;
528
+ const interpolate = isPlainObject(options.processor) &&
529
+ isFunction(options.processor.interpolate)
530
+ ? options.processor.interpolate
531
+ : DEFAULT_INTERPOLATE;
532
+ const type = isPlainObject(options.processor) && isString(options.processor.type)
533
+ ? options.processor.type
534
+ : DEFAULT_MESSAGE_DATA_TYPE;
535
+ const linked = (key, ...args) => {
536
+ const [arg1, arg2] = args;
537
+ let type = 'text';
538
+ let modifier = '';
539
+ if (args.length === 1) {
540
+ if (isObject(arg1)) {
541
+ modifier = arg1.modifier || modifier;
542
+ type = arg1.type || type;
543
+ }
544
+ else if (isString(arg1)) {
545
+ modifier = arg1 || modifier;
546
+ }
547
+ }
548
+ else if (args.length === 2) {
549
+ if (isString(arg1)) {
550
+ modifier = arg1 || modifier;
551
+ }
552
+ if (isString(arg2)) {
553
+ type = arg2 || type;
554
+ }
555
+ }
556
+ let msg = message(key)(ctx);
557
+ // The message in vnode resolved with linked are returned as an array by processor.nomalize
558
+ if (type === 'vnode' && isArray(msg) && modifier) {
559
+ msg = msg[0];
560
+ }
561
+ return modifier ? _modifier(modifier)(msg, type) : msg;
562
+ };
563
+ const ctx = {
564
+ ["list" /* HelperNameMap.LIST */]: list,
565
+ ["named" /* HelperNameMap.NAMED */]: named,
566
+ ["plural" /* HelperNameMap.PLURAL */]: plural,
567
+ ["linked" /* HelperNameMap.LINKED */]: linked,
568
+ ["message" /* HelperNameMap.MESSAGE */]: message,
569
+ ["type" /* HelperNameMap.TYPE */]: type,
570
+ ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate,
571
+ ["normalize" /* HelperNameMap.NORMALIZE */]: normalize
572
+ };
573
+ return ctx;
574
+ }
575
+
576
+ const IntlifyDevToolsHooks = {
577
+ I18nInit: 'i18n:init',
578
+ FunctionTranslate: 'function:translate'
579
+ };
580
+
581
+ let devtools = null;
582
+ function setDevToolsHook(hook) {
583
+ devtools = hook;
584
+ }
585
+ function getDevToolsHook() {
586
+ return devtools;
587
+ }
588
+ function initI18nDevTools(i18n, version, meta) {
589
+ // TODO: queue if devtools is undefined
590
+ devtools &&
591
+ devtools.emit(IntlifyDevToolsHooks.I18nInit, {
592
+ timestamp: Date.now(),
593
+ i18n,
594
+ version,
595
+ meta
596
+ });
597
+ }
598
+ const translateDevTools = /* #__PURE__*/ createDevToolsHook(IntlifyDevToolsHooks.FunctionTranslate);
599
+ function createDevToolsHook(hook) {
600
+ return (payloads) => devtools && devtools.emit(hook, payloads);
601
+ }
602
+
603
+ const CoreWarnCodes = {
604
+ NOT_FOUND_KEY: 1,
605
+ FALLBACK_TO_TRANSLATE: 2,
606
+ CANNOT_FORMAT_NUMBER: 3,
607
+ FALLBACK_TO_NUMBER_FORMAT: 4,
608
+ CANNOT_FORMAT_DATE: 5,
609
+ FALLBACK_TO_DATE_FORMAT: 6,
610
+ __EXTEND_POINT__: 7
611
+ };
612
+ /** @internal */
613
+ const warnMessages = {
614
+ [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
615
+ [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
616
+ [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
617
+ [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
618
+ [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
619
+ [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`
620
+ };
621
+ function getWarnMessage(code, ...args) {
622
+ return format(warnMessages[code], ...args);
623
+ }
624
+
625
+ /**
626
+ * Fallback with simple implemenation
627
+ *
628
+ * @remarks
629
+ * A fallback locale function implemented with a simple fallback algorithm.
630
+ *
631
+ * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify.
632
+ *
633
+ * @param ctx - A {@link CoreContext | context}
634
+ * @param fallback - A {@link FallbackLocale | fallback locale}
635
+ * @param start - A starting {@link Locale | locale}
636
+ *
637
+ * @returns Fallback locales
638
+ *
639
+ * @VueI18nGeneral
640
+ */
641
+ function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars
642
+ ) {
643
+ // prettier-ignore
644
+ return [...new Set([
645
+ start,
646
+ ...(isArray(fallback)
647
+ ? fallback
648
+ : isObject(fallback)
649
+ ? Object.keys(fallback)
650
+ : isString(fallback)
651
+ ? [fallback]
652
+ : [start])
653
+ ])];
654
+ }
655
+ /**
656
+ * Fallback with locale chain
657
+ *
658
+ * @remarks
659
+ * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default.
660
+ *
661
+ * @param ctx - A {@link CoreContext | context}
662
+ * @param fallback - A {@link FallbackLocale | fallback locale}
663
+ * @param start - A starting {@link Locale | locale}
664
+ *
665
+ * @returns Fallback locales
666
+ *
667
+ * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
668
+ *
669
+ * @VueI18nGeneral
670
+ */
671
+ function fallbackWithLocaleChain(ctx, fallback, start) {
672
+ const startLocale = isString(start) ? start : DEFAULT_LOCALE;
673
+ const context = ctx;
674
+ if (!context.__localeChainCache) {
675
+ context.__localeChainCache = new Map();
676
+ }
677
+ let chain = context.__localeChainCache.get(startLocale);
678
+ if (!chain) {
679
+ chain = [];
680
+ // first block defined by start
681
+ let block = [start];
682
+ // while any intervening block found
683
+ while (isArray(block)) {
684
+ block = appendBlockToChain(chain, block, fallback);
685
+ }
686
+ // prettier-ignore
687
+ // last block defined by default
688
+ const defaults = isArray(fallback) || !isPlainObject(fallback)
689
+ ? fallback
690
+ : fallback['default']
691
+ ? fallback['default']
692
+ : null;
693
+ // convert defaults to array
694
+ block = isString(defaults) ? [defaults] : defaults;
695
+ if (isArray(block)) {
696
+ appendBlockToChain(chain, block, false);
697
+ }
698
+ context.__localeChainCache.set(startLocale, chain);
699
+ }
700
+ return chain;
701
+ }
702
+ function appendBlockToChain(chain, block, blocks) {
703
+ let follow = true;
704
+ for (let i = 0; i < block.length && isBoolean(follow); i++) {
705
+ const locale = block[i];
706
+ if (isString(locale)) {
707
+ follow = appendLocaleToChain(chain, block[i], blocks);
708
+ }
709
+ }
710
+ return follow;
711
+ }
712
+ function appendLocaleToChain(chain, locale, blocks) {
713
+ let follow;
714
+ const tokens = locale.split('-');
715
+ do {
716
+ const target = tokens.join('-');
717
+ follow = appendItemToChain(chain, target, blocks);
718
+ tokens.splice(-1, 1);
719
+ } while (tokens.length && follow === true);
720
+ return follow;
721
+ }
722
+ function appendItemToChain(chain, target, blocks) {
723
+ let follow = false;
724
+ if (!chain.includes(target)) {
725
+ follow = true;
726
+ if (target) {
727
+ follow = target[target.length - 1] !== '!';
728
+ const locale = target.replace(/!/g, '');
729
+ chain.push(locale);
730
+ if ((isArray(blocks) || isPlainObject(blocks)) &&
731
+ blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any
732
+ ) {
733
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
734
+ follow = blocks[locale];
735
+ }
736
+ }
737
+ }
738
+ return follow;
739
+ }
740
+
741
+ /* eslint-disable @typescript-eslint/no-explicit-any */
742
+ /**
743
+ * Intlify core-base version
744
+ * @internal
745
+ */
746
+ const VERSION = '9.3.0-beta.11';
747
+ const NOT_REOSLVED = -1;
748
+ const DEFAULT_LOCALE = 'en-US';
749
+ const MISSING_RESOLVE_VALUE = '';
750
+ const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
751
+ function getDefaultLinkedModifiers() {
752
+ return {
753
+ upper: (val, type) => {
754
+ // prettier-ignore
755
+ return type === 'text' && isString(val)
756
+ ? val.toUpperCase()
757
+ : type === 'vnode' && isObject(val) && '__v_isVNode' in val
758
+ ? val.children.toUpperCase()
759
+ : val;
760
+ },
761
+ lower: (val, type) => {
762
+ // prettier-ignore
763
+ return type === 'text' && isString(val)
764
+ ? val.toLowerCase()
765
+ : type === 'vnode' && isObject(val) && '__v_isVNode' in val
766
+ ? val.children.toLowerCase()
767
+ : val;
768
+ },
769
+ capitalize: (val, type) => {
770
+ // prettier-ignore
771
+ return (type === 'text' && isString(val)
772
+ ? capitalize(val)
773
+ : type === 'vnode' && isObject(val) && '__v_isVNode' in val
774
+ ? capitalize(val.children)
775
+ : val);
776
+ }
777
+ };
778
+ }
779
+ let _compiler;
780
+ function registerMessageCompiler(compiler) {
781
+ _compiler = compiler;
782
+ }
783
+ let _resolver;
784
+ /**
785
+ * Register the message resolver
786
+ *
787
+ * @param resolver - A {@link MessageResolver} function
788
+ *
789
+ * @VueI18nGeneral
790
+ */
791
+ function registerMessageResolver(resolver) {
792
+ _resolver = resolver;
793
+ }
794
+ let _fallbacker;
795
+ /**
796
+ * Register the locale fallbacker
797
+ *
798
+ * @param fallbacker - A {@link LocaleFallbacker} function
799
+ *
800
+ * @VueI18nGeneral
801
+ */
802
+ function registerLocaleFallbacker(fallbacker) {
803
+ _fallbacker = fallbacker;
804
+ }
805
+ // Additional Meta for Intlify DevTools
806
+ let _additionalMeta = null;
807
+ const setAdditionalMeta = (meta) => {
808
+ _additionalMeta = meta;
809
+ };
810
+ const getAdditionalMeta = () => _additionalMeta;
811
+ let _fallbackContext = null;
812
+ const setFallbackContext = (context) => {
813
+ _fallbackContext = context;
814
+ };
815
+ const getFallbackContext = () => _fallbackContext;
816
+ // ID for CoreContext
817
+ let _cid = 0;
818
+ function createCoreContext(options = {}) {
819
+ // setup options
820
+ const version = isString(options.version) ? options.version : VERSION;
821
+ const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE;
822
+ const fallbackLocale = isArray(options.fallbackLocale) ||
823
+ isPlainObject(options.fallbackLocale) ||
824
+ isString(options.fallbackLocale) ||
825
+ options.fallbackLocale === false
826
+ ? options.fallbackLocale
827
+ : locale;
828
+ const messages = isPlainObject(options.messages)
829
+ ? options.messages
830
+ : { [locale]: {} };
831
+ const datetimeFormats = isPlainObject(options.datetimeFormats)
832
+ ? options.datetimeFormats
833
+ : { [locale]: {} }
834
+ ;
835
+ const numberFormats = isPlainObject(options.numberFormats)
836
+ ? options.numberFormats
837
+ : { [locale]: {} }
838
+ ;
839
+ const modifiers = assign({}, options.modifiers || {}, getDefaultLinkedModifiers());
840
+ const pluralRules = options.pluralRules || {};
841
+ const missing = isFunction(options.missing) ? options.missing : null;
842
+ const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
843
+ ? options.missingWarn
844
+ : true;
845
+ const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn)
846
+ ? options.fallbackWarn
847
+ : true;
848
+ const fallbackFormat = !!options.fallbackFormat;
849
+ const unresolving = !!options.unresolving;
850
+ const postTranslation = isFunction(options.postTranslation)
851
+ ? options.postTranslation
852
+ : null;
853
+ const processor = isPlainObject(options.processor) ? options.processor : null;
854
+ const warnHtmlMessage = isBoolean(options.warnHtmlMessage)
855
+ ? options.warnHtmlMessage
856
+ : true;
857
+ const escapeParameter = !!options.escapeParameter;
858
+ const messageCompiler = isFunction(options.messageCompiler)
859
+ ? options.messageCompiler
860
+ : _compiler;
861
+ const messageResolver = isFunction(options.messageResolver)
862
+ ? options.messageResolver
863
+ : _resolver || resolveWithKeyValue;
864
+ const localeFallbacker = isFunction(options.localeFallbacker)
865
+ ? options.localeFallbacker
866
+ : _fallbacker || fallbackWithSimple;
867
+ const fallbackContext = isObject(options.fallbackContext)
868
+ ? options.fallbackContext
869
+ : undefined;
870
+ const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
871
+ // setup internal options
872
+ const internalOptions = options;
873
+ const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters)
874
+ ? internalOptions.__datetimeFormatters
875
+ : new Map()
876
+ ;
877
+ const __numberFormatters = isObject(internalOptions.__numberFormatters)
878
+ ? internalOptions.__numberFormatters
879
+ : new Map()
880
+ ;
881
+ const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {};
882
+ _cid++;
883
+ const context = {
884
+ version,
885
+ cid: _cid,
886
+ locale,
887
+ fallbackLocale,
888
+ messages,
889
+ modifiers,
890
+ pluralRules,
891
+ missing,
892
+ missingWarn,
893
+ fallbackWarn,
894
+ fallbackFormat,
895
+ unresolving,
896
+ postTranslation,
897
+ processor,
898
+ warnHtmlMessage,
899
+ escapeParameter,
900
+ messageCompiler,
901
+ messageResolver,
902
+ localeFallbacker,
903
+ fallbackContext,
904
+ onWarn,
905
+ __meta
906
+ };
907
+ {
908
+ context.datetimeFormats = datetimeFormats;
909
+ context.numberFormats = numberFormats;
910
+ context.__datetimeFormatters = __datetimeFormatters;
911
+ context.__numberFormatters = __numberFormatters;
912
+ }
913
+ // for vue-devtools timeline event
914
+ {
915
+ context.__v_emitter =
916
+ internalOptions.__v_emitter != null
917
+ ? internalOptions.__v_emitter
918
+ : undefined;
919
+ }
920
+ // NOTE: experimental !!
921
+ {
922
+ initI18nDevTools(context, version, __meta);
923
+ }
924
+ return context;
925
+ }
926
+ /** @internal */
927
+ function isTranslateFallbackWarn(fallback, key) {
928
+ return fallback instanceof RegExp ? fallback.test(key) : fallback;
929
+ }
930
+ /** @internal */
931
+ function isTranslateMissingWarn(missing, key) {
932
+ return missing instanceof RegExp ? missing.test(key) : missing;
933
+ }
934
+ /** @internal */
935
+ function handleMissing(context, key, locale, missingWarn, type) {
936
+ const { missing, onWarn } = context;
937
+ // for vue-devtools timeline event
938
+ {
939
+ const emitter = context.__v_emitter;
940
+ if (emitter) {
941
+ emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, {
942
+ locale,
943
+ key,
944
+ type,
945
+ groupId: `${type}:${key}`
946
+ });
947
+ }
948
+ }
949
+ if (missing !== null) {
950
+ const ret = missing(context, locale, key, type);
951
+ return isString(ret) ? ret : key;
952
+ }
953
+ else {
954
+ if (isTranslateMissingWarn(missingWarn, key)) {
955
+ onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale }));
956
+ }
957
+ return key;
958
+ }
959
+ }
960
+ /** @internal */
961
+ function updateFallbackLocale(ctx, locale, fallback) {
962
+ const context = ctx;
963
+ context.__localeChainCache = new Map();
964
+ ctx.localeFallbacker(ctx, fallback, locale);
965
+ }
966
+ /* eslint-enable @typescript-eslint/no-explicit-any */
967
+
968
+ function clearCompileCache() {
969
+ }
970
+ function compileToFunction(source, options = {}) {
971
+ {
972
+ warn(`Runtime compilation is not supported in ${'core.runtime.esm-browser.js' }.`);
973
+ return (() => source);
974
+ }
975
+ }
976
+
977
+ let code = CompileErrorCodes.__EXTEND_POINT__;
978
+ const inc = () => ++code;
979
+ const CoreErrorCodes = {
980
+ INVALID_ARGUMENT: code,
981
+ INVALID_DATE_ARGUMENT: inc(),
982
+ INVALID_ISO_DATE_ARGUMENT: inc(),
983
+ __EXTEND_POINT__: inc() // 18
984
+ };
985
+ function createCoreError(code) {
986
+ return createCompileError(code, null, { messages: errorMessages } );
987
+ }
988
+ /** @internal */
989
+ const errorMessages = {
990
+ [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments',
991
+ [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' +
992
+ 'Make sure your Date represents a valid date.',
993
+ [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string'
994
+ };
995
+
996
+ const NOOP_MESSAGE_FUNCTION = () => '';
997
+ const isMessageFunction = (val) => isFunction(val);
998
+ // implementation of `translate` function
999
+ function translate(context, ...args) {
1000
+ const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context;
1001
+ const [key, options] = parseTranslateArgs(...args);
1002
+ const missingWarn = isBoolean(options.missingWarn)
1003
+ ? options.missingWarn
1004
+ : context.missingWarn;
1005
+ const fallbackWarn = isBoolean(options.fallbackWarn)
1006
+ ? options.fallbackWarn
1007
+ : context.fallbackWarn;
1008
+ const escapeParameter = isBoolean(options.escapeParameter)
1009
+ ? options.escapeParameter
1010
+ : context.escapeParameter;
1011
+ const resolvedMessage = !!options.resolvedMessage;
1012
+ // prettier-ignore
1013
+ const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option
1014
+ ? !isBoolean(options.default)
1015
+ ? options.default
1016
+ : (!messageCompiler ? () => key : key)
1017
+ : fallbackFormat // default by `fallbackFormat` option
1018
+ ? (!messageCompiler ? () => key : key)
1019
+ : '';
1020
+ const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== '';
1021
+ const locale = isString(options.locale) ? options.locale : context.locale;
1022
+ // escape params
1023
+ escapeParameter && escapeParams(options);
1024
+ // resolve message format
1025
+ // eslint-disable-next-line prefer-const
1026
+ let [formatScope, targetLocale, message] = !resolvedMessage
1027
+ ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn)
1028
+ : [
1029
+ key,
1030
+ locale,
1031
+ messages[locale] || {}
1032
+ ];
1033
+ // NOTE:
1034
+ // Fix to work around `ssrTransfrom` bug in Vite.
1035
+ // https://github.com/vitejs/vite/issues/4306
1036
+ // To get around this, use temporary variables.
1037
+ // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243
1038
+ let format = formatScope;
1039
+ // if you use default message, set it as message format!
1040
+ let cacheBaseKey = key;
1041
+ if (!resolvedMessage &&
1042
+ !(isString(format) || isMessageFunction(format))) {
1043
+ if (enableDefaultMsg) {
1044
+ format = defaultMsgOrKey;
1045
+ cacheBaseKey = format;
1046
+ }
1047
+ }
1048
+ // checking message format and target locale
1049
+ if (!resolvedMessage &&
1050
+ (!(isString(format) || isMessageFunction(format)) ||
1051
+ !isString(targetLocale))) {
1052
+ return unresolving ? NOT_REOSLVED : key;
1053
+ }
1054
+ if (isString(format) && context.messageCompiler == null) {
1055
+ warn(`The message format compilation is not supported in this build. ` +
1056
+ `Because message compiler isn't included. ` +
1057
+ `You need to pre-compilation all message format. ` +
1058
+ `So translate function return '${key}'.`);
1059
+ return key;
1060
+ }
1061
+ // setup compile error detecting
1062
+ let occurred = false;
1063
+ const errorDetector = () => {
1064
+ occurred = true;
1065
+ };
1066
+ // compile message format
1067
+ const msg = !isMessageFunction(format)
1068
+ ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector)
1069
+ : format;
1070
+ // if occurred compile error, return the message format
1071
+ if (occurred) {
1072
+ return format;
1073
+ }
1074
+ // evaluate message with context
1075
+ const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
1076
+ const msgContext = createMessageContext(ctxOptions);
1077
+ const messaged = evaluateMessage(context, msg, msgContext);
1078
+ // if use post translation option, proceed it with handler
1079
+ const ret = postTranslation
1080
+ ? postTranslation(messaged, key)
1081
+ : messaged;
1082
+ // NOTE: experimental !!
1083
+ {
1084
+ // prettier-ignore
1085
+ const payloads = {
1086
+ timestamp: Date.now(),
1087
+ key: isString(key)
1088
+ ? key
1089
+ : isMessageFunction(format)
1090
+ ? format.key
1091
+ : '',
1092
+ locale: targetLocale || (isMessageFunction(format)
1093
+ ? format.locale
1094
+ : ''),
1095
+ format: isString(format)
1096
+ ? format
1097
+ : isMessageFunction(format)
1098
+ ? format.source
1099
+ : '',
1100
+ message: ret
1101
+ };
1102
+ payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {});
1103
+ translateDevTools(payloads);
1104
+ }
1105
+ return ret;
1106
+ }
1107
+ function escapeParams(options) {
1108
+ if (isArray(options.list)) {
1109
+ options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item);
1110
+ }
1111
+ else if (isObject(options.named)) {
1112
+ Object.keys(options.named).forEach(key => {
1113
+ if (isString(options.named[key])) {
1114
+ options.named[key] = escapeHtml(options.named[key]);
1115
+ }
1116
+ });
1117
+ }
1118
+ }
1119
+ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
1120
+ const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
1121
+ const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any
1122
+ let message = {};
1123
+ let targetLocale;
1124
+ let format = null;
1125
+ let from = locale;
1126
+ let to = null;
1127
+ const type = 'translate';
1128
+ for (let i = 0; i < locales.length; i++) {
1129
+ targetLocale = to = locales[i];
1130
+ if (locale !== targetLocale &&
1131
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1132
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
1133
+ key,
1134
+ target: targetLocale
1135
+ }));
1136
+ }
1137
+ // for vue-devtools timeline event
1138
+ if (locale !== targetLocale) {
1139
+ const emitter = context.__v_emitter;
1140
+ if (emitter) {
1141
+ emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, {
1142
+ type,
1143
+ key,
1144
+ from,
1145
+ to,
1146
+ groupId: `${type}:${key}`
1147
+ });
1148
+ }
1149
+ }
1150
+ message =
1151
+ messages[targetLocale] || {};
1152
+ // for vue-devtools timeline event
1153
+ let start = null;
1154
+ let startTag;
1155
+ let endTag;
1156
+ if (inBrowser) {
1157
+ start = window.performance.now();
1158
+ startTag = 'intlify-message-resolve-start';
1159
+ endTag = 'intlify-message-resolve-end';
1160
+ mark && mark(startTag);
1161
+ }
1162
+ if ((format = resolveValue(message, key)) === null) {
1163
+ // if null, resolve with object key path
1164
+ format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any
1165
+ }
1166
+ // for vue-devtools timeline event
1167
+ if (inBrowser) {
1168
+ const end = window.performance.now();
1169
+ const emitter = context.__v_emitter;
1170
+ if (emitter && start && format) {
1171
+ emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, {
1172
+ type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */,
1173
+ key,
1174
+ message: format,
1175
+ time: end - start,
1176
+ groupId: `${type}:${key}`
1177
+ });
1178
+ }
1179
+ if (startTag && endTag && mark && measure) {
1180
+ mark(endTag);
1181
+ measure('intlify message resolve', startTag, endTag);
1182
+ }
1183
+ }
1184
+ if (isString(format) || isFunction(format))
1185
+ break;
1186
+ const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any
1187
+ key, targetLocale, missingWarn, type);
1188
+ if (missingRet !== key) {
1189
+ format = missingRet;
1190
+ }
1191
+ from = to;
1192
+ }
1193
+ return [format, targetLocale, message];
1194
+ }
1195
+ function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) {
1196
+ const { messageCompiler, warnHtmlMessage } = context;
1197
+ if (isMessageFunction(format)) {
1198
+ const msg = format;
1199
+ msg.locale = msg.locale || targetLocale;
1200
+ msg.key = msg.key || key;
1201
+ return msg;
1202
+ }
1203
+ if (messageCompiler == null) {
1204
+ const msg = (() => format);
1205
+ msg.locale = targetLocale;
1206
+ msg.key = key;
1207
+ return msg;
1208
+ }
1209
+ // for vue-devtools timeline event
1210
+ let start = null;
1211
+ let startTag;
1212
+ let endTag;
1213
+ if (inBrowser) {
1214
+ start = window.performance.now();
1215
+ startTag = 'intlify-message-compilation-start';
1216
+ endTag = 'intlify-message-compilation-end';
1217
+ mark && mark(startTag);
1218
+ }
1219
+ const msg = messageCompiler(format, getCompileOptions(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, errorDetector));
1220
+ // for vue-devtools timeline event
1221
+ if (inBrowser) {
1222
+ const end = window.performance.now();
1223
+ const emitter = context.__v_emitter;
1224
+ if (emitter && start) {
1225
+ emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, {
1226
+ type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */,
1227
+ message: format,
1228
+ time: end - start,
1229
+ groupId: `${'translate'}:${key}`
1230
+ });
1231
+ }
1232
+ if (startTag && endTag && mark && measure) {
1233
+ mark(endTag);
1234
+ measure('intlify message compilation', startTag, endTag);
1235
+ }
1236
+ }
1237
+ msg.locale = targetLocale;
1238
+ msg.key = key;
1239
+ msg.source = format;
1240
+ return msg;
1241
+ }
1242
+ function evaluateMessage(context, msg, msgCtx) {
1243
+ // for vue-devtools timeline event
1244
+ let start = null;
1245
+ let startTag;
1246
+ let endTag;
1247
+ if (inBrowser) {
1248
+ start = window.performance.now();
1249
+ startTag = 'intlify-message-evaluation-start';
1250
+ endTag = 'intlify-message-evaluation-end';
1251
+ mark && mark(startTag);
1252
+ }
1253
+ const messaged = msg(msgCtx);
1254
+ // for vue-devtools timeline event
1255
+ if (inBrowser) {
1256
+ const end = window.performance.now();
1257
+ const emitter = context.__v_emitter;
1258
+ if (emitter && start) {
1259
+ emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, {
1260
+ type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */,
1261
+ value: messaged,
1262
+ time: end - start,
1263
+ groupId: `${'translate'}:${msg.key}`
1264
+ });
1265
+ }
1266
+ if (startTag && endTag && mark && measure) {
1267
+ mark(endTag);
1268
+ measure('intlify message evaluation', startTag, endTag);
1269
+ }
1270
+ }
1271
+ return messaged;
1272
+ }
1273
+ /** @internal */
1274
+ function parseTranslateArgs(...args) {
1275
+ const [arg1, arg2, arg3] = args;
1276
+ const options = {};
1277
+ if (!isString(arg1) && !isNumber(arg1) && !isMessageFunction(arg1)) {
1278
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
1279
+ }
1280
+ // prettier-ignore
1281
+ const key = isNumber(arg1)
1282
+ ? String(arg1)
1283
+ : isMessageFunction(arg1)
1284
+ ? arg1
1285
+ : arg1;
1286
+ if (isNumber(arg2)) {
1287
+ options.plural = arg2;
1288
+ }
1289
+ else if (isString(arg2)) {
1290
+ options.default = arg2;
1291
+ }
1292
+ else if (isPlainObject(arg2) && !isEmptyObject(arg2)) {
1293
+ options.named = arg2;
1294
+ }
1295
+ else if (isArray(arg2)) {
1296
+ options.list = arg2;
1297
+ }
1298
+ if (isNumber(arg3)) {
1299
+ options.plural = arg3;
1300
+ }
1301
+ else if (isString(arg3)) {
1302
+ options.default = arg3;
1303
+ }
1304
+ else if (isPlainObject(arg3)) {
1305
+ assign(options, arg3);
1306
+ }
1307
+ return [key, options];
1308
+ }
1309
+ function getCompileOptions(context, locale, key, source, warnHtmlMessage, errorDetector) {
1310
+ return {
1311
+ warnHtmlMessage,
1312
+ onError: (err) => {
1313
+ errorDetector && errorDetector(err);
1314
+ {
1315
+ const message = `Message compilation error: ${err.message}`;
1316
+ const codeFrame = err.location &&
1317
+ generateCodeFrame(source, err.location.start.offset, err.location.end.offset);
1318
+ const emitter = context.__v_emitter;
1319
+ if (emitter) {
1320
+ emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, {
1321
+ message: source,
1322
+ error: err.message,
1323
+ start: err.location && err.location.start.offset,
1324
+ end: err.location && err.location.end.offset,
1325
+ groupId: `${'translate'}:${key}`
1326
+ });
1327
+ }
1328
+ console.error(codeFrame ? `${message}\n${codeFrame}` : message);
1329
+ }
1330
+ },
1331
+ onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
1332
+ };
1333
+ }
1334
+ function getMessageContextOptions(context, locale, message, options) {
1335
+ const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
1336
+ const resolveMessage = (key) => {
1337
+ let val = resolveValue(message, key);
1338
+ // fallback to root context
1339
+ if (val == null && fallbackContext) {
1340
+ const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn);
1341
+ val = resolveValue(message, key);
1342
+ }
1343
+ if (isString(val)) {
1344
+ let occurred = false;
1345
+ const errorDetector = () => {
1346
+ occurred = true;
1347
+ };
1348
+ const msg = compileMessageFormat(context, key, locale, val, key, errorDetector);
1349
+ return !occurred
1350
+ ? msg
1351
+ : NOOP_MESSAGE_FUNCTION;
1352
+ }
1353
+ else if (isMessageFunction(val)) {
1354
+ return val;
1355
+ }
1356
+ else {
1357
+ // TODO: should be implemented warning message
1358
+ return NOOP_MESSAGE_FUNCTION;
1359
+ }
1360
+ };
1361
+ const ctxOptions = {
1362
+ locale,
1363
+ modifiers,
1364
+ pluralRules,
1365
+ messages: resolveMessage
1366
+ };
1367
+ if (context.processor) {
1368
+ ctxOptions.processor = context.processor;
1369
+ }
1370
+ if (options.list) {
1371
+ ctxOptions.list = options.list;
1372
+ }
1373
+ if (options.named) {
1374
+ ctxOptions.named = options.named;
1375
+ }
1376
+ if (isNumber(options.plural)) {
1377
+ ctxOptions.pluralIndex = options.plural;
1378
+ }
1379
+ return ctxOptions;
1380
+ }
1381
+
1382
+ const intlDefined = typeof Intl !== 'undefined';
1383
+ const Availabilities = {
1384
+ dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
1385
+ numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
1386
+ };
1387
+
1388
+ // implementation of `datetime` function
1389
+ function datetime(context, ...args) {
1390
+ const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
1391
+ const { __datetimeFormatters } = context;
1392
+ if (!Availabilities.dateTimeFormat) {
1393
+ onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
1394
+ return MISSING_RESOLVE_VALUE;
1395
+ }
1396
+ const [key, value, options, overrides] = parseDateTimeArgs(...args);
1397
+ const missingWarn = isBoolean(options.missingWarn)
1398
+ ? options.missingWarn
1399
+ : context.missingWarn;
1400
+ const fallbackWarn = isBoolean(options.fallbackWarn)
1401
+ ? options.fallbackWarn
1402
+ : context.fallbackWarn;
1403
+ const part = !!options.part;
1404
+ const locale = isString(options.locale) ? options.locale : context.locale;
1405
+ const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any
1406
+ fallbackLocale, locale);
1407
+ if (!isString(key) || key === '') {
1408
+ return new Intl.DateTimeFormat(locale, overrides).format(value);
1409
+ }
1410
+ // resolve format
1411
+ let datetimeFormat = {};
1412
+ let targetLocale;
1413
+ let format = null;
1414
+ let from = locale;
1415
+ let to = null;
1416
+ const type = 'datetime format';
1417
+ for (let i = 0; i < locales.length; i++) {
1418
+ targetLocale = to = locales[i];
1419
+ if (locale !== targetLocale &&
1420
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1421
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, {
1422
+ key,
1423
+ target: targetLocale
1424
+ }));
1425
+ }
1426
+ // for vue-devtools timeline event
1427
+ if (locale !== targetLocale) {
1428
+ const emitter = context.__v_emitter;
1429
+ if (emitter) {
1430
+ emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, {
1431
+ type,
1432
+ key,
1433
+ from,
1434
+ to,
1435
+ groupId: `${type}:${key}`
1436
+ });
1437
+ }
1438
+ }
1439
+ datetimeFormat =
1440
+ datetimeFormats[targetLocale] || {};
1441
+ format = datetimeFormat[key];
1442
+ if (isPlainObject(format))
1443
+ break;
1444
+ handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any
1445
+ from = to;
1446
+ }
1447
+ // checking format and target locale
1448
+ if (!isPlainObject(format) || !isString(targetLocale)) {
1449
+ return unresolving ? NOT_REOSLVED : key;
1450
+ }
1451
+ let id = `${targetLocale}__${key}`;
1452
+ if (!isEmptyObject(overrides)) {
1453
+ id = `${id}__${JSON.stringify(overrides)}`;
1454
+ }
1455
+ let formatter = __datetimeFormatters.get(id);
1456
+ if (!formatter) {
1457
+ formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides));
1458
+ __datetimeFormatters.set(id, formatter);
1459
+ }
1460
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
1461
+ }
1462
+ /** @internal */
1463
+ const DATETIME_FORMAT_OPTIONS_KEYS = [
1464
+ 'localeMatcher',
1465
+ 'weekday',
1466
+ 'era',
1467
+ 'year',
1468
+ 'month',
1469
+ 'day',
1470
+ 'hour',
1471
+ 'minute',
1472
+ 'second',
1473
+ 'timeZoneName',
1474
+ 'formatMatcher',
1475
+ 'hour12',
1476
+ 'timeZone',
1477
+ 'dateStyle',
1478
+ 'timeStyle',
1479
+ 'calendar',
1480
+ 'dayPeriod',
1481
+ 'numberingSystem',
1482
+ 'hourCycle',
1483
+ 'fractionalSecondDigits'
1484
+ ];
1485
+ /** @internal */
1486
+ function parseDateTimeArgs(...args) {
1487
+ const [arg1, arg2, arg3, arg4] = args;
1488
+ const options = {};
1489
+ let overrides = {};
1490
+ let value;
1491
+ if (isString(arg1)) {
1492
+ // Only allow ISO strings - other date formats are often supported,
1493
+ // but may cause different results in different browsers.
1494
+ const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
1495
+ if (!matches) {
1496
+ throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
1497
+ }
1498
+ // Some browsers can not parse the iso datetime separated by space,
1499
+ // this is a compromise solution by replace the 'T'/' ' with 'T'
1500
+ const dateTime = matches[3]
1501
+ ? matches[3].trim().startsWith('T')
1502
+ ? `${matches[1].trim()}${matches[3].trim()}`
1503
+ : `${matches[1].trim()}T${matches[3].trim()}`
1504
+ : matches[1].trim();
1505
+ value = new Date(dateTime);
1506
+ try {
1507
+ // This will fail if the date is not valid
1508
+ value.toISOString();
1509
+ }
1510
+ catch (e) {
1511
+ throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
1512
+ }
1513
+ }
1514
+ else if (isDate(arg1)) {
1515
+ if (isNaN(arg1.getTime())) {
1516
+ throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT);
1517
+ }
1518
+ value = arg1;
1519
+ }
1520
+ else if (isNumber(arg1)) {
1521
+ value = arg1;
1522
+ }
1523
+ else {
1524
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
1525
+ }
1526
+ if (isString(arg2)) {
1527
+ options.key = arg2;
1528
+ }
1529
+ else if (isPlainObject(arg2)) {
1530
+ Object.keys(arg2).forEach(key => {
1531
+ if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) {
1532
+ overrides[key] = arg2[key];
1533
+ }
1534
+ else {
1535
+ options[key] = arg2[key];
1536
+ }
1537
+ });
1538
+ }
1539
+ if (isString(arg3)) {
1540
+ options.locale = arg3;
1541
+ }
1542
+ else if (isPlainObject(arg3)) {
1543
+ overrides = arg3;
1544
+ }
1545
+ if (isPlainObject(arg4)) {
1546
+ overrides = arg4;
1547
+ }
1548
+ return [options.key || '', value, options, overrides];
1549
+ }
1550
+ /** @internal */
1551
+ function clearDateTimeFormat(ctx, locale, format) {
1552
+ const context = ctx;
1553
+ for (const key in format) {
1554
+ const id = `${locale}__${key}`;
1555
+ if (!context.__datetimeFormatters.has(id)) {
1556
+ continue;
1557
+ }
1558
+ context.__datetimeFormatters.delete(id);
1559
+ }
1560
+ }
1561
+
1562
+ // implementation of `number` function
1563
+ function number(context, ...args) {
1564
+ const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
1565
+ const { __numberFormatters } = context;
1566
+ if (!Availabilities.numberFormat) {
1567
+ onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
1568
+ return MISSING_RESOLVE_VALUE;
1569
+ }
1570
+ const [key, value, options, overrides] = parseNumberArgs(...args);
1571
+ const missingWarn = isBoolean(options.missingWarn)
1572
+ ? options.missingWarn
1573
+ : context.missingWarn;
1574
+ const fallbackWarn = isBoolean(options.fallbackWarn)
1575
+ ? options.fallbackWarn
1576
+ : context.fallbackWarn;
1577
+ const part = !!options.part;
1578
+ const locale = isString(options.locale) ? options.locale : context.locale;
1579
+ const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any
1580
+ fallbackLocale, locale);
1581
+ if (!isString(key) || key === '') {
1582
+ return new Intl.NumberFormat(locale, overrides).format(value);
1583
+ }
1584
+ // resolve format
1585
+ let numberFormat = {};
1586
+ let targetLocale;
1587
+ let format = null;
1588
+ let from = locale;
1589
+ let to = null;
1590
+ const type = 'number format';
1591
+ for (let i = 0; i < locales.length; i++) {
1592
+ targetLocale = to = locales[i];
1593
+ if (locale !== targetLocale &&
1594
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1595
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
1596
+ key,
1597
+ target: targetLocale
1598
+ }));
1599
+ }
1600
+ // for vue-devtools timeline event
1601
+ if (locale !== targetLocale) {
1602
+ const emitter = context.__v_emitter;
1603
+ if (emitter) {
1604
+ emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, {
1605
+ type,
1606
+ key,
1607
+ from,
1608
+ to,
1609
+ groupId: `${type}:${key}`
1610
+ });
1611
+ }
1612
+ }
1613
+ numberFormat =
1614
+ numberFormats[targetLocale] || {};
1615
+ format = numberFormat[key];
1616
+ if (isPlainObject(format))
1617
+ break;
1618
+ handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any
1619
+ from = to;
1620
+ }
1621
+ // checking format and target locale
1622
+ if (!isPlainObject(format) || !isString(targetLocale)) {
1623
+ return unresolving ? NOT_REOSLVED : key;
1624
+ }
1625
+ let id = `${targetLocale}__${key}`;
1626
+ if (!isEmptyObject(overrides)) {
1627
+ id = `${id}__${JSON.stringify(overrides)}`;
1628
+ }
1629
+ let formatter = __numberFormatters.get(id);
1630
+ if (!formatter) {
1631
+ formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides));
1632
+ __numberFormatters.set(id, formatter);
1633
+ }
1634
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
1635
+ }
1636
+ /** @internal */
1637
+ const NUMBER_FORMAT_OPTIONS_KEYS = [
1638
+ 'localeMatcher',
1639
+ 'style',
1640
+ 'currency',
1641
+ 'currencyDisplay',
1642
+ 'currencySign',
1643
+ 'useGrouping',
1644
+ 'minimumIntegerDigits',
1645
+ 'minimumFractionDigits',
1646
+ 'maximumFractionDigits',
1647
+ 'minimumSignificantDigits',
1648
+ 'maximumSignificantDigits',
1649
+ 'compactDisplay',
1650
+ 'notation',
1651
+ 'signDisplay',
1652
+ 'unit',
1653
+ 'unitDisplay',
1654
+ 'roundingMode',
1655
+ 'roundingPriority',
1656
+ 'roundingIncrement',
1657
+ 'trailingZeroDisplay'
1658
+ ];
1659
+ /** @internal */
1660
+ function parseNumberArgs(...args) {
1661
+ const [arg1, arg2, arg3, arg4] = args;
1662
+ const options = {};
1663
+ let overrides = {};
1664
+ if (!isNumber(arg1)) {
1665
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
1666
+ }
1667
+ const value = arg1;
1668
+ if (isString(arg2)) {
1669
+ options.key = arg2;
1670
+ }
1671
+ else if (isPlainObject(arg2)) {
1672
+ Object.keys(arg2).forEach(key => {
1673
+ if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) {
1674
+ overrides[key] = arg2[key];
1675
+ }
1676
+ else {
1677
+ options[key] = arg2[key];
1678
+ }
1679
+ });
1680
+ }
1681
+ if (isString(arg3)) {
1682
+ options.locale = arg3;
1683
+ }
1684
+ else if (isPlainObject(arg3)) {
1685
+ overrides = arg3;
1686
+ }
1687
+ if (isPlainObject(arg4)) {
1688
+ overrides = arg4;
1689
+ }
1690
+ return [options.key || '', value, options, overrides];
1691
+ }
1692
+ /** @internal */
1693
+ function clearNumberFormat(ctx, locale, format) {
1694
+ const context = ctx;
1695
+ for (const key in format) {
1696
+ const id = `${locale}__${key}`;
1697
+ if (!context.__numberFormatters.has(id)) {
1698
+ continue;
1699
+ }
1700
+ context.__numberFormatters.delete(id);
1701
+ }
1702
+ }
1703
+
1704
+ // register message resolver at @intlify/core
1705
+ registerMessageResolver(resolveValue);
1706
+ // register fallback locale at @intlify/core
1707
+ registerLocaleFallbacker(fallbackWithLocaleChain);
1708
+
1709
+ export { CompileErrorCodes, CoreErrorCodes, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_REOSLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compileToFunction, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getAdditionalMeta, getDevToolsHook, getFallbackContext, getWarnMessage, handleMissing, initI18nDevTools, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveValue, resolveWithKeyValue, setAdditionalMeta, setDevToolsHook, setFallbackContext, translate, translateDevTools, updateFallbackLocale };