@intlify/core-base 9.11.1 → 9.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-base.cjs +36 -18
- package/dist/core-base.d.ts +9 -9
- package/dist/core-base.esm-browser.js +123 -51
- package/dist/core-base.esm-browser.prod.js +2 -2
- package/dist/core-base.global.js +123 -51
- package/dist/core-base.global.prod.js +2 -2
- package/dist/core-base.mjs +38 -20
- package/dist/core-base.prod.cjs +20 -18
- package/package.json +5 -5
package/dist/core-base.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* core-base v9.
|
|
2
|
+
* core-base v9.12.1
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -428,15 +428,17 @@ function createDevToolsHook(hook) {
|
|
|
428
428
|
return (payloads) => devtools && devtools.emit(hook, payloads);
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
+
const code$1 = messageCompiler.CompileWarnCodes.__EXTEND_POINT__;
|
|
432
|
+
const inc$1 = shared.incrementer(code$1);
|
|
431
433
|
const CoreWarnCodes = {
|
|
432
|
-
NOT_FOUND_KEY: 1,
|
|
433
|
-
FALLBACK_TO_TRANSLATE:
|
|
434
|
-
CANNOT_FORMAT_NUMBER:
|
|
435
|
-
FALLBACK_TO_NUMBER_FORMAT:
|
|
436
|
-
CANNOT_FORMAT_DATE:
|
|
437
|
-
FALLBACK_TO_DATE_FORMAT:
|
|
438
|
-
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:
|
|
439
|
-
__EXTEND_POINT__:
|
|
434
|
+
NOT_FOUND_KEY: code$1, // 2
|
|
435
|
+
FALLBACK_TO_TRANSLATE: inc$1(), // 3
|
|
436
|
+
CANNOT_FORMAT_NUMBER: inc$1(), // 4
|
|
437
|
+
FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5
|
|
438
|
+
CANNOT_FORMAT_DATE: inc$1(), // 6
|
|
439
|
+
FALLBACK_TO_DATE_FORMAT: inc$1(), // 7
|
|
440
|
+
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8
|
|
441
|
+
__EXTEND_POINT__: inc$1() // 9
|
|
440
442
|
};
|
|
441
443
|
/** @internal */
|
|
442
444
|
const warnMessages = {
|
|
@@ -455,14 +457,14 @@ function getWarnMessage(code, ...args) {
|
|
|
455
457
|
const code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__;
|
|
456
458
|
const inc = shared.incrementer(code);
|
|
457
459
|
const CoreErrorCodes = {
|
|
458
|
-
INVALID_ARGUMENT: code, //
|
|
459
|
-
INVALID_DATE_ARGUMENT: inc(), //
|
|
460
|
-
INVALID_ISO_DATE_ARGUMENT: inc(), //
|
|
461
|
-
NOT_SUPPORT_NON_STRING_MESSAGE: inc(), //
|
|
462
|
-
NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), //
|
|
463
|
-
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), //
|
|
464
|
-
NOT_SUPPORT_LOCALE_TYPE: inc(), //
|
|
465
|
-
__EXTEND_POINT__: inc() //
|
|
460
|
+
INVALID_ARGUMENT: code, // 17
|
|
461
|
+
INVALID_DATE_ARGUMENT: inc(), // 18
|
|
462
|
+
INVALID_ISO_DATE_ARGUMENT: inc(), // 19
|
|
463
|
+
NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20
|
|
464
|
+
NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21
|
|
465
|
+
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22
|
|
466
|
+
NOT_SUPPORT_LOCALE_TYPE: inc(), // 23
|
|
467
|
+
__EXTEND_POINT__: inc() // 24
|
|
466
468
|
};
|
|
467
469
|
function createCoreError(code) {
|
|
468
470
|
return messageCompiler.createCompileError(code, null, { messages: errorMessages } );
|
|
@@ -633,7 +635,7 @@ function appendItemToChain(chain, target, blocks) {
|
|
|
633
635
|
* Intlify core-base version
|
|
634
636
|
* @internal
|
|
635
637
|
*/
|
|
636
|
-
const VERSION = '9.
|
|
638
|
+
const VERSION = '9.12.1';
|
|
637
639
|
const NOT_REOSLVED = -1;
|
|
638
640
|
const DEFAULT_LOCALE = 'en-US';
|
|
639
641
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -938,6 +940,14 @@ function checkHtmlMessage(source, warnHtmlMessage) {
|
|
|
938
940
|
}
|
|
939
941
|
const defaultOnCacheKey = (message) => message;
|
|
940
942
|
let compileCache = Object.create(null);
|
|
943
|
+
function onCompileWarn(_warn) {
|
|
944
|
+
if (_warn.code === messageCompiler.CompileWarnCodes.USE_MODULO_SYNTAX) {
|
|
945
|
+
shared.warn(`The use of named interpolation with modulo syntax is deprecated. ` +
|
|
946
|
+
`It will be removed in v10.\n` +
|
|
947
|
+
`reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` +
|
|
948
|
+
`(message compiler warning message: ${_warn.message})`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
941
951
|
function clearCompileCache() {
|
|
942
952
|
compileCache = Object.create(null);
|
|
943
953
|
}
|
|
@@ -960,6 +970,10 @@ const compileToFunction = (message, context) => {
|
|
|
960
970
|
if (!shared.isString(message)) {
|
|
961
971
|
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE);
|
|
962
972
|
}
|
|
973
|
+
// set onWarn
|
|
974
|
+
{
|
|
975
|
+
context.onWarn = onCompileWarn;
|
|
976
|
+
}
|
|
963
977
|
{
|
|
964
978
|
// check HTML message
|
|
965
979
|
const warnHtmlMessage = shared.isBoolean(context.warnHtmlMessage)
|
|
@@ -984,6 +998,10 @@ const compileToFunction = (message, context) => {
|
|
|
984
998
|
}
|
|
985
999
|
};
|
|
986
1000
|
function compile(message, context) {
|
|
1001
|
+
// set onWarn
|
|
1002
|
+
{
|
|
1003
|
+
context.onWarn = onCompileWarn;
|
|
1004
|
+
}
|
|
987
1005
|
if (shared.isString(message)) {
|
|
988
1006
|
// check HTML message
|
|
989
1007
|
const warnHtmlMessage = shared.isBoolean(context.warnHtmlMessage)
|
package/dist/core-base.d.ts
CHANGED
|
@@ -167,14 +167,14 @@ export declare interface CoreTranslationContext<Messages = {}, Message = string>
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export declare const CoreWarnCodes: {
|
|
170
|
-
readonly NOT_FOUND_KEY:
|
|
171
|
-
readonly FALLBACK_TO_TRANSLATE:
|
|
172
|
-
readonly CANNOT_FORMAT_NUMBER:
|
|
173
|
-
readonly FALLBACK_TO_NUMBER_FORMAT:
|
|
174
|
-
readonly CANNOT_FORMAT_DATE:
|
|
175
|
-
readonly FALLBACK_TO_DATE_FORMAT:
|
|
176
|
-
readonly EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:
|
|
177
|
-
readonly __EXTEND_POINT__:
|
|
170
|
+
readonly NOT_FOUND_KEY: 2;
|
|
171
|
+
readonly FALLBACK_TO_TRANSLATE: number;
|
|
172
|
+
readonly CANNOT_FORMAT_NUMBER: number;
|
|
173
|
+
readonly FALLBACK_TO_NUMBER_FORMAT: number;
|
|
174
|
+
readonly CANNOT_FORMAT_DATE: number;
|
|
175
|
+
readonly FALLBACK_TO_DATE_FORMAT: number;
|
|
176
|
+
readonly EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: number;
|
|
177
|
+
readonly __EXTEND_POINT__: number;
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
export declare type CoreWarnCodes = (typeof CoreWarnCodes)[keyof typeof CoreWarnCodes];
|
|
@@ -561,7 +561,7 @@ export declare type MessageCompiler<Message = string, MessageSource = string | R
|
|
|
561
561
|
*
|
|
562
562
|
* @VueI18nGeneral
|
|
563
563
|
*/
|
|
564
|
-
export declare type MessageCompilerContext = Pick<CompileOptions, 'onError' | 'onCacheKey'> & {
|
|
564
|
+
export declare type MessageCompilerContext = Pick<CompileOptions, 'onError' | 'onCacheKey' | 'onWarn'> & {
|
|
565
565
|
/**
|
|
566
566
|
* Whether to allow the use locale messages of HTML formatting.
|
|
567
567
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* core-base v9.
|
|
2
|
+
* core-base v9.12.1
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -161,6 +161,23 @@ function createLocation(start, end, source) {
|
|
|
161
161
|
return loc;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
const CompileWarnCodes = {
|
|
165
|
+
USE_MODULO_SYNTAX: 1,
|
|
166
|
+
__EXTEND_POINT__: 2
|
|
167
|
+
};
|
|
168
|
+
/** @internal */
|
|
169
|
+
const warnMessages$1 = {
|
|
170
|
+
[CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.`
|
|
171
|
+
};
|
|
172
|
+
function createCompileWarn(code, loc, ...args) {
|
|
173
|
+
const msg = format$1(warnMessages$1[code] || '', ...(args || [])) ;
|
|
174
|
+
const message = { message: String(msg), code };
|
|
175
|
+
if (loc) {
|
|
176
|
+
message.location = loc;
|
|
177
|
+
}
|
|
178
|
+
return message;
|
|
179
|
+
}
|
|
180
|
+
|
|
164
181
|
const CompileErrorCodes = {
|
|
165
182
|
// tokenizer error codes
|
|
166
183
|
EXPECTED_TOKEN: 1,
|
|
@@ -554,33 +571,46 @@ function createTokenizer(source, options = {}) {
|
|
|
554
571
|
}
|
|
555
572
|
return null;
|
|
556
573
|
}
|
|
574
|
+
function isIdentifier(ch) {
|
|
575
|
+
const cc = ch.charCodeAt(0);
|
|
576
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
577
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
578
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
579
|
+
cc === 95 || // _
|
|
580
|
+
cc === 36 // $
|
|
581
|
+
);
|
|
582
|
+
}
|
|
557
583
|
function takeIdentifierChar(scnr) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
584
|
+
return takeChar(scnr, isIdentifier);
|
|
585
|
+
}
|
|
586
|
+
function isNamedIdentifier(ch) {
|
|
587
|
+
const cc = ch.charCodeAt(0);
|
|
588
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
589
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
590
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
591
|
+
cc === 95 || // _
|
|
592
|
+
cc === 36 || // $
|
|
593
|
+
cc === 45 // -
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
function takeNamedIdentifierChar(scnr) {
|
|
597
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
598
|
+
}
|
|
599
|
+
function isDigit(ch) {
|
|
600
|
+
const cc = ch.charCodeAt(0);
|
|
601
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
568
602
|
}
|
|
569
603
|
function takeDigit(scnr) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return
|
|
604
|
+
return takeChar(scnr, isDigit);
|
|
605
|
+
}
|
|
606
|
+
function isHexDigit(ch) {
|
|
607
|
+
const cc = ch.charCodeAt(0);
|
|
608
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
609
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
610
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
575
611
|
}
|
|
576
612
|
function takeHexDigit(scnr) {
|
|
577
|
-
|
|
578
|
-
const cc = ch.charCodeAt(0);
|
|
579
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
580
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
581
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
582
|
-
};
|
|
583
|
-
return takeChar(scnr, closure);
|
|
613
|
+
return takeChar(scnr, isHexDigit);
|
|
584
614
|
}
|
|
585
615
|
function getDigits(scnr) {
|
|
586
616
|
let ch = '';
|
|
@@ -644,7 +674,7 @@ function createTokenizer(source, options = {}) {
|
|
|
644
674
|
skipSpaces(scnr);
|
|
645
675
|
let ch = '';
|
|
646
676
|
let name = '';
|
|
647
|
-
while ((ch =
|
|
677
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
648
678
|
name += ch;
|
|
649
679
|
}
|
|
650
680
|
if (scnr.currentChar() === EOF) {
|
|
@@ -667,14 +697,16 @@ function createTokenizer(source, options = {}) {
|
|
|
667
697
|
}
|
|
668
698
|
return value;
|
|
669
699
|
}
|
|
700
|
+
function isLiteral(ch) {
|
|
701
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
702
|
+
}
|
|
670
703
|
function readLiteral(scnr) {
|
|
671
704
|
skipSpaces(scnr);
|
|
672
705
|
// eslint-disable-next-line no-useless-escape
|
|
673
706
|
eat(scnr, `\'`);
|
|
674
707
|
let ch = '';
|
|
675
708
|
let literal = '';
|
|
676
|
-
|
|
677
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
709
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
678
710
|
if (ch === '\\') {
|
|
679
711
|
literal += readEscapeSequence(scnr);
|
|
680
712
|
}
|
|
@@ -726,15 +758,17 @@ function createTokenizer(source, options = {}) {
|
|
|
726
758
|
}
|
|
727
759
|
return `\\${unicode}${sequence}`;
|
|
728
760
|
}
|
|
761
|
+
function isInvalidIdentifier(ch) {
|
|
762
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
763
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
764
|
+
ch !== CHAR_SP &&
|
|
765
|
+
ch !== CHAR_LF);
|
|
766
|
+
}
|
|
729
767
|
function readInvalidIdentifier(scnr) {
|
|
730
768
|
skipSpaces(scnr);
|
|
731
769
|
let ch = '';
|
|
732
770
|
let identifiers = '';
|
|
733
|
-
|
|
734
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
735
|
-
ch !== CHAR_SP &&
|
|
736
|
-
ch !== CHAR_LF;
|
|
737
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
771
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
738
772
|
identifiers += ch;
|
|
739
773
|
}
|
|
740
774
|
return identifiers;
|
|
@@ -1011,7 +1045,7 @@ function fromEscapeSequence(match, codePoint4, codePoint6) {
|
|
|
1011
1045
|
}
|
|
1012
1046
|
function createParser(options = {}) {
|
|
1013
1047
|
const location = options.location !== false;
|
|
1014
|
-
const { onError } = options;
|
|
1048
|
+
const { onError, onWarn } = options;
|
|
1015
1049
|
function emitError(tokenzer, code, start, offset, ...args) {
|
|
1016
1050
|
const end = tokenzer.currentPosition();
|
|
1017
1051
|
end.offset += offset;
|
|
@@ -1025,6 +1059,15 @@ function createParser(options = {}) {
|
|
|
1025
1059
|
onError(err);
|
|
1026
1060
|
}
|
|
1027
1061
|
}
|
|
1062
|
+
function emitWarn(tokenzer, code, start, offset, ...args) {
|
|
1063
|
+
const end = tokenzer.currentPosition();
|
|
1064
|
+
end.offset += offset;
|
|
1065
|
+
end.column += offset;
|
|
1066
|
+
if (onWarn) {
|
|
1067
|
+
const loc = location ? createLocation(start, end) : null;
|
|
1068
|
+
onWarn(createCompileWarn(code, loc, args));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1028
1071
|
function startNode(type, offset, loc) {
|
|
1029
1072
|
const node = { type };
|
|
1030
1073
|
if (location) {
|
|
@@ -1061,11 +1104,14 @@ function createParser(options = {}) {
|
|
|
1061
1104
|
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1062
1105
|
return node;
|
|
1063
1106
|
}
|
|
1064
|
-
function parseNamed(tokenizer, key) {
|
|
1107
|
+
function parseNamed(tokenizer, key, modulo) {
|
|
1065
1108
|
const context = tokenizer.context();
|
|
1066
1109
|
const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
|
|
1067
1110
|
const node = startNode(4 /* NodeTypes.Named */, offset, loc);
|
|
1068
1111
|
node.key = key;
|
|
1112
|
+
if (modulo === true) {
|
|
1113
|
+
node.modulo = true;
|
|
1114
|
+
}
|
|
1069
1115
|
tokenizer.nextToken(); // skip brach right
|
|
1070
1116
|
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1071
1117
|
return node;
|
|
@@ -1185,6 +1231,7 @@ function createParser(options = {}) {
|
|
|
1185
1231
|
const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc);
|
|
1186
1232
|
node.items = [];
|
|
1187
1233
|
let nextToken = null;
|
|
1234
|
+
let modulo = null;
|
|
1188
1235
|
do {
|
|
1189
1236
|
const token = nextToken || tokenizer.nextToken();
|
|
1190
1237
|
nextToken = null;
|
|
@@ -1201,11 +1248,18 @@ function createParser(options = {}) {
|
|
|
1201
1248
|
}
|
|
1202
1249
|
node.items.push(parseList(tokenizer, token.value || ''));
|
|
1203
1250
|
break;
|
|
1251
|
+
case 4 /* TokenTypes.Modulo */:
|
|
1252
|
+
modulo = true;
|
|
1253
|
+
break;
|
|
1204
1254
|
case 5 /* TokenTypes.Named */:
|
|
1205
1255
|
if (token.value == null) {
|
|
1206
1256
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1207
1257
|
}
|
|
1208
|
-
node.items.push(parseNamed(tokenizer, token.value || ''));
|
|
1258
|
+
node.items.push(parseNamed(tokenizer, token.value || '', !!modulo));
|
|
1259
|
+
if (modulo) {
|
|
1260
|
+
emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1261
|
+
modulo = null;
|
|
1262
|
+
}
|
|
1209
1263
|
break;
|
|
1210
1264
|
case 7 /* TokenTypes.Literal */:
|
|
1211
1265
|
if (token.value == null) {
|
|
@@ -2106,15 +2160,17 @@ function createDevToolsHook(hook) {
|
|
|
2106
2160
|
return (payloads) => devtools && devtools.emit(hook, payloads);
|
|
2107
2161
|
}
|
|
2108
2162
|
|
|
2163
|
+
const code$1 = CompileWarnCodes.__EXTEND_POINT__;
|
|
2164
|
+
const inc$1 = incrementer(code$1);
|
|
2109
2165
|
const CoreWarnCodes = {
|
|
2110
|
-
NOT_FOUND_KEY: 1,
|
|
2111
|
-
FALLBACK_TO_TRANSLATE:
|
|
2112
|
-
CANNOT_FORMAT_NUMBER:
|
|
2113
|
-
FALLBACK_TO_NUMBER_FORMAT:
|
|
2114
|
-
CANNOT_FORMAT_DATE:
|
|
2115
|
-
FALLBACK_TO_DATE_FORMAT:
|
|
2116
|
-
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:
|
|
2117
|
-
__EXTEND_POINT__:
|
|
2166
|
+
NOT_FOUND_KEY: code$1, // 2
|
|
2167
|
+
FALLBACK_TO_TRANSLATE: inc$1(), // 3
|
|
2168
|
+
CANNOT_FORMAT_NUMBER: inc$1(), // 4
|
|
2169
|
+
FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5
|
|
2170
|
+
CANNOT_FORMAT_DATE: inc$1(), // 6
|
|
2171
|
+
FALLBACK_TO_DATE_FORMAT: inc$1(), // 7
|
|
2172
|
+
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8
|
|
2173
|
+
__EXTEND_POINT__: inc$1() // 9
|
|
2118
2174
|
};
|
|
2119
2175
|
/** @internal */
|
|
2120
2176
|
const warnMessages = {
|
|
@@ -2133,14 +2189,14 @@ function getWarnMessage(code, ...args) {
|
|
|
2133
2189
|
const code = CompileErrorCodes.__EXTEND_POINT__;
|
|
2134
2190
|
const inc = incrementer(code);
|
|
2135
2191
|
const CoreErrorCodes = {
|
|
2136
|
-
INVALID_ARGUMENT: code, //
|
|
2137
|
-
INVALID_DATE_ARGUMENT: inc(), //
|
|
2138
|
-
INVALID_ISO_DATE_ARGUMENT: inc(), //
|
|
2139
|
-
NOT_SUPPORT_NON_STRING_MESSAGE: inc(), //
|
|
2140
|
-
NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), //
|
|
2141
|
-
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), //
|
|
2142
|
-
NOT_SUPPORT_LOCALE_TYPE: inc(), //
|
|
2143
|
-
__EXTEND_POINT__: inc() //
|
|
2192
|
+
INVALID_ARGUMENT: code, // 17
|
|
2193
|
+
INVALID_DATE_ARGUMENT: inc(), // 18
|
|
2194
|
+
INVALID_ISO_DATE_ARGUMENT: inc(), // 19
|
|
2195
|
+
NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20
|
|
2196
|
+
NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21
|
|
2197
|
+
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22
|
|
2198
|
+
NOT_SUPPORT_LOCALE_TYPE: inc(), // 23
|
|
2199
|
+
__EXTEND_POINT__: inc() // 24
|
|
2144
2200
|
};
|
|
2145
2201
|
function createCoreError(code) {
|
|
2146
2202
|
return createCompileError(code, null, { messages: errorMessages } );
|
|
@@ -2311,7 +2367,7 @@ function appendItemToChain(chain, target, blocks) {
|
|
|
2311
2367
|
* Intlify core-base version
|
|
2312
2368
|
* @internal
|
|
2313
2369
|
*/
|
|
2314
|
-
const VERSION = '9.
|
|
2370
|
+
const VERSION = '9.12.1';
|
|
2315
2371
|
const NOT_REOSLVED = -1;
|
|
2316
2372
|
const DEFAULT_LOCALE = 'en-US';
|
|
2317
2373
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -2616,6 +2672,14 @@ function checkHtmlMessage(source, warnHtmlMessage) {
|
|
|
2616
2672
|
}
|
|
2617
2673
|
const defaultOnCacheKey = (message) => message;
|
|
2618
2674
|
let compileCache = Object.create(null);
|
|
2675
|
+
function onCompileWarn(_warn) {
|
|
2676
|
+
if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) {
|
|
2677
|
+
warn(`The use of named interpolation with modulo syntax is deprecated. ` +
|
|
2678
|
+
`It will be removed in v10.\n` +
|
|
2679
|
+
`reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` +
|
|
2680
|
+
`(message compiler warning message: ${_warn.message})`);
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2619
2683
|
function clearCompileCache() {
|
|
2620
2684
|
compileCache = Object.create(null);
|
|
2621
2685
|
}
|
|
@@ -2638,6 +2702,10 @@ const compileToFunction = (message, context) => {
|
|
|
2638
2702
|
if (!isString(message)) {
|
|
2639
2703
|
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE);
|
|
2640
2704
|
}
|
|
2705
|
+
// set onWarn
|
|
2706
|
+
{
|
|
2707
|
+
context.onWarn = onCompileWarn;
|
|
2708
|
+
}
|
|
2641
2709
|
{
|
|
2642
2710
|
// check HTML message
|
|
2643
2711
|
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|
|
@@ -2662,6 +2730,10 @@ const compileToFunction = (message, context) => {
|
|
|
2662
2730
|
}
|
|
2663
2731
|
};
|
|
2664
2732
|
function compile(message, context) {
|
|
2733
|
+
// set onWarn
|
|
2734
|
+
{
|
|
2735
|
+
context.onWarn = onCompileWarn;
|
|
2736
|
+
}
|
|
2665
2737
|
if (isString(message)) {
|
|
2666
2738
|
// check HTML message
|
|
2667
2739
|
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|