vue-i18n 9.3.0 → 9.4.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/README.md +10 -0
- package/dist/vue-i18n.cjs +4 -4
- package/dist/vue-i18n.esm-browser.js +104 -29
- package/dist/vue-i18n.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.global.js +104 -29
- package/dist/vue-i18n.global.prod.js +2 -2
- package/dist/vue-i18n.mjs +19 -8
- package/dist/vue-i18n.prod.cjs +3 -3
- package/dist/vue-i18n.runtime.esm-browser.js +6 -11
- package/dist/vue-i18n.runtime.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.runtime.global.js +6 -11
- package/dist/vue-i18n.runtime.global.prod.js +2 -2
- package/dist/vue-i18n.runtime.mjs +15 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -39,10 +39,20 @@ Internationalization plugin for Vue.js
|
|
|
39
39
|
### For Node.js (Server-Side)
|
|
40
40
|
|
|
41
41
|
- **`vue-i18n.cjs(.prod).js`**:
|
|
42
|
+
- For CommonJS usage in Node.js
|
|
42
43
|
- For use in Node.js via `require()`
|
|
43
44
|
- If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded
|
|
44
45
|
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
|
|
45
46
|
|
|
47
|
+
- **`vue-i18n.node.mjs`**:
|
|
48
|
+
- For ES Moudles usage in Node.js
|
|
49
|
+
- For use in Node.js via `import`
|
|
50
|
+
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env`<wbr/>`.NODE_ENV`
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
> NOTE: ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n.node.mjs`. 9.3+
|
|
54
|
+
|
|
55
|
+
|
|
46
56
|
## For Bundler feature flags
|
|
47
57
|
|
|
48
58
|
### Build Feature Flags
|
package/dist/vue-i18n.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v9.
|
|
2
|
+
* vue-i18n v9.4.1
|
|
3
3
|
* (c) 2023 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -17,7 +17,7 @@ var vue = require('vue');
|
|
|
17
17
|
*
|
|
18
18
|
* @VueI18nGeneral
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = '9.
|
|
20
|
+
const VERSION = '9.4.1';
|
|
21
21
|
|
|
22
22
|
const code$1 = coreBase.CoreWarnCodes.__EXTEND_POINT__;
|
|
23
23
|
const inc$1 = shared.incrementer(code$1);
|
|
@@ -1751,7 +1751,7 @@ function createI18n(options = {}, VueI18nLegacy) {
|
|
|
1751
1751
|
const [globalScope, __global] = createGlobal(options, __legacyMode);
|
|
1752
1752
|
const symbol = /* #__PURE__*/ shared.makeSymbol('vue-i18n' );
|
|
1753
1753
|
{
|
|
1754
|
-
if (__legacyMode && __allowComposition) {
|
|
1754
|
+
if (__legacyMode && __allowComposition && !false) {
|
|
1755
1755
|
shared.warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION));
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
@@ -2431,7 +2431,7 @@ function injectGlobalFields(app, composer) {
|
|
|
2431
2431
|
|
|
2432
2432
|
// register message compiler at vue-i18n
|
|
2433
2433
|
{
|
|
2434
|
-
coreBase.registerMessageCompiler(coreBase.
|
|
2434
|
+
coreBase.registerMessageCompiler(coreBase.compile);
|
|
2435
2435
|
}
|
|
2436
2436
|
// register message resolver at vue-i18n
|
|
2437
2437
|
coreBase.registerMessageResolver(coreBase.resolveValue);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v9.
|
|
2
|
+
* vue-i18n v9.4.1
|
|
3
3
|
* (c) 2023 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -32,7 +32,7 @@ let measure;
|
|
|
32
32
|
}
|
|
33
33
|
const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g;
|
|
34
34
|
/* eslint-disable */
|
|
35
|
-
function format(message, ...args) {
|
|
35
|
+
function format$1(message, ...args) {
|
|
36
36
|
if (args.length === 1 && isObject(args[0])) {
|
|
37
37
|
args = args[0];
|
|
38
38
|
}
|
|
@@ -271,7 +271,7 @@ const errorMessages$2 = {
|
|
|
271
271
|
};
|
|
272
272
|
function createCompileError(code, loc, options = {}) {
|
|
273
273
|
const { domain, messages, args } = options;
|
|
274
|
-
const msg = format((messages || errorMessages$2)[code] || '', ...(args || []))
|
|
274
|
+
const msg = format$1((messages || errorMessages$2)[code] || '', ...(args || []))
|
|
275
275
|
;
|
|
276
276
|
const error = new SyntaxError(String(msg));
|
|
277
277
|
error.code = code;
|
|
@@ -808,6 +808,8 @@ function createTokenizer(source, options = {}) {
|
|
|
808
808
|
ch === "%" /* TokenChars.Modulo */ ||
|
|
809
809
|
ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
810
810
|
ch === "|" /* TokenChars.Pipe */ ||
|
|
811
|
+
ch === "(" /* TokenChars.ParenLeft */ ||
|
|
812
|
+
ch === ")" /* TokenChars.ParenRight */ ||
|
|
811
813
|
!ch) {
|
|
812
814
|
return buf;
|
|
813
815
|
}
|
|
@@ -819,9 +821,6 @@ function createTokenizer(source, options = {}) {
|
|
|
819
821
|
scnr.next();
|
|
820
822
|
return fn(detect, buf);
|
|
821
823
|
}
|
|
822
|
-
else if (!isIdentifierStart(ch)) {
|
|
823
|
-
return buf;
|
|
824
|
-
}
|
|
825
824
|
else {
|
|
826
825
|
buf += ch;
|
|
827
826
|
scnr.next();
|
|
@@ -2120,11 +2119,6 @@ function createMessageContext(options = {}) {
|
|
|
2120
2119
|
return ctx;
|
|
2121
2120
|
}
|
|
2122
2121
|
|
|
2123
|
-
const IntlifyDevToolsHooks = {
|
|
2124
|
-
I18nInit: 'i18n:init',
|
|
2125
|
-
FunctionTranslate: 'function:translate'
|
|
2126
|
-
};
|
|
2127
|
-
|
|
2128
2122
|
let devtools = null;
|
|
2129
2123
|
function setDevToolsHook(hook) {
|
|
2130
2124
|
devtools = hook;
|
|
@@ -2132,14 +2126,14 @@ function setDevToolsHook(hook) {
|
|
|
2132
2126
|
function initI18nDevTools(i18n, version, meta) {
|
|
2133
2127
|
// TODO: queue if devtools is undefined
|
|
2134
2128
|
devtools &&
|
|
2135
|
-
devtools.emit(IntlifyDevToolsHooks.I18nInit
|
|
2129
|
+
devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, {
|
|
2136
2130
|
timestamp: Date.now(),
|
|
2137
2131
|
i18n,
|
|
2138
2132
|
version,
|
|
2139
2133
|
meta
|
|
2140
2134
|
});
|
|
2141
2135
|
}
|
|
2142
|
-
const translateDevTools = /* #__PURE__*/ createDevToolsHook(IntlifyDevToolsHooks.FunctionTranslate);
|
|
2136
|
+
const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */);
|
|
2143
2137
|
function createDevToolsHook(hook) {
|
|
2144
2138
|
return (payloads) => devtools && devtools.emit(hook, payloads);
|
|
2145
2139
|
}
|
|
@@ -2165,7 +2159,7 @@ const warnMessages$1 = {
|
|
|
2165
2159
|
[CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.`
|
|
2166
2160
|
};
|
|
2167
2161
|
function getWarnMessage$1(code, ...args) {
|
|
2168
|
-
return format(warnMessages$1[code], ...args);
|
|
2162
|
+
return format$1(warnMessages$1[code], ...args);
|
|
2169
2163
|
}
|
|
2170
2164
|
|
|
2171
2165
|
/**
|
|
@@ -2289,7 +2283,7 @@ function appendItemToChain(chain, target, blocks) {
|
|
|
2289
2283
|
* Intlify core-base version
|
|
2290
2284
|
* @internal
|
|
2291
2285
|
*/
|
|
2292
|
-
const VERSION$1 = '9.
|
|
2286
|
+
const VERSION$1 = '9.4.1';
|
|
2293
2287
|
const NOT_REOSLVED = -1;
|
|
2294
2288
|
const DEFAULT_LOCALE = 'en-US';
|
|
2295
2289
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -2514,6 +2508,66 @@ function updateFallbackLocale(ctx, locale, fallback) {
|
|
|
2514
2508
|
}
|
|
2515
2509
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
2516
2510
|
|
|
2511
|
+
function format(ast) {
|
|
2512
|
+
const msg = (ctx) => formatParts(ctx, ast);
|
|
2513
|
+
return msg;
|
|
2514
|
+
}
|
|
2515
|
+
function formatParts(ctx, ast) {
|
|
2516
|
+
const body = ast.b || ast.body;
|
|
2517
|
+
if ((body.t || body.type) === 1 /* NodeTypes.Plural */) {
|
|
2518
|
+
const plural = body;
|
|
2519
|
+
const cases = plural.c || plural.cases;
|
|
2520
|
+
return ctx.plural(cases.reduce((messages, c) => [
|
|
2521
|
+
...messages,
|
|
2522
|
+
formatMessageParts(ctx, c)
|
|
2523
|
+
], []));
|
|
2524
|
+
}
|
|
2525
|
+
else {
|
|
2526
|
+
return formatMessageParts(ctx, body);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
function formatMessageParts(ctx, node) {
|
|
2530
|
+
const _static = node.s || node.static;
|
|
2531
|
+
if (_static) {
|
|
2532
|
+
return ctx.type === 'text'
|
|
2533
|
+
? _static
|
|
2534
|
+
: ctx.normalize([_static]);
|
|
2535
|
+
}
|
|
2536
|
+
else {
|
|
2537
|
+
const messages = (node.i || node.items).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []);
|
|
2538
|
+
return ctx.normalize(messages);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function formatMessagePart(ctx, node) {
|
|
2542
|
+
const type = node.t || node.type;
|
|
2543
|
+
switch (type) {
|
|
2544
|
+
case 3 /* NodeTypes.Text */:
|
|
2545
|
+
const text = node;
|
|
2546
|
+
return (text.v || text.value);
|
|
2547
|
+
case 9 /* NodeTypes.Literal */:
|
|
2548
|
+
const literal = node;
|
|
2549
|
+
return (literal.v || literal.value);
|
|
2550
|
+
case 4 /* NodeTypes.Named */:
|
|
2551
|
+
const named = node;
|
|
2552
|
+
return ctx.interpolate(ctx.named(named.k || named.key));
|
|
2553
|
+
case 5 /* NodeTypes.List */:
|
|
2554
|
+
const list = node;
|
|
2555
|
+
return ctx.interpolate(ctx.list(list.i || list.index));
|
|
2556
|
+
case 6 /* NodeTypes.Linked */:
|
|
2557
|
+
const linked = node;
|
|
2558
|
+
const modifier = linked.m || linked.modifier;
|
|
2559
|
+
return ctx.linked(formatMessagePart(ctx, linked.k || linked.key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type);
|
|
2560
|
+
case 7 /* NodeTypes.LinkedKey */:
|
|
2561
|
+
const linkedKey = node;
|
|
2562
|
+
return (linkedKey.v || linkedKey.value);
|
|
2563
|
+
case 8 /* NodeTypes.LinkedModifier */:
|
|
2564
|
+
const linkedModifier = node;
|
|
2565
|
+
return (linkedModifier.v || linkedModifier.value);
|
|
2566
|
+
default:
|
|
2567
|
+
throw new Error(`unhandled node type on format message part: ${type}`);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2517
2571
|
const code$2 = CompileErrorCodes.__EXTEND_POINT__;
|
|
2518
2572
|
const inc$2 = incrementer(code$2);
|
|
2519
2573
|
const CoreErrorCodes = {
|
|
@@ -2538,7 +2592,7 @@ const errorMessages$1 = {
|
|
|
2538
2592
|
const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`;
|
|
2539
2593
|
function checkHtmlMessage(source, warnHtmlMessage) {
|
|
2540
2594
|
if (warnHtmlMessage && detectHtmlTag(source)) {
|
|
2541
|
-
warn(format(WARN_MESSAGE, { source }));
|
|
2595
|
+
warn(format$1(WARN_MESSAGE, { source }));
|
|
2542
2596
|
}
|
|
2543
2597
|
}
|
|
2544
2598
|
const defaultOnCacheKey = (message) => message;
|
|
@@ -2557,11 +2611,8 @@ function baseCompile(message, options = {}) {
|
|
|
2557
2611
|
// compile with mesasge-compiler
|
|
2558
2612
|
return { ...baseCompile$1(message, options), detectError };
|
|
2559
2613
|
}
|
|
2560
|
-
function
|
|
2561
|
-
if (
|
|
2562
|
-
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE);
|
|
2563
|
-
}
|
|
2564
|
-
{
|
|
2614
|
+
function compile(message, context) {
|
|
2615
|
+
if (isString(message)) {
|
|
2565
2616
|
// check HTML message
|
|
2566
2617
|
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|
|
2567
2618
|
? context.warnHtmlMessage
|
|
@@ -2574,15 +2625,39 @@ function compileToFunction(message, context) {
|
|
|
2574
2625
|
if (cached) {
|
|
2575
2626
|
return cached;
|
|
2576
2627
|
}
|
|
2577
|
-
// compile
|
|
2578
|
-
const {
|
|
2579
|
-
|
|
2580
|
-
|
|
2628
|
+
// compile with JIT mode
|
|
2629
|
+
const { ast, detectError } = baseCompile(message, {
|
|
2630
|
+
...context,
|
|
2631
|
+
location: true,
|
|
2632
|
+
jit: true
|
|
2633
|
+
});
|
|
2634
|
+
// compose message function from AST
|
|
2635
|
+
const msg = format(ast);
|
|
2581
2636
|
// if occurred compile error, don't cache
|
|
2582
2637
|
return !detectError
|
|
2583
2638
|
? (compileCache[cacheKey] = msg)
|
|
2584
2639
|
: msg;
|
|
2585
2640
|
}
|
|
2641
|
+
else {
|
|
2642
|
+
if (!isMessageAST(message)) {
|
|
2643
|
+
warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`);
|
|
2644
|
+
return (() => message);
|
|
2645
|
+
}
|
|
2646
|
+
// AST case (passed from bundler)
|
|
2647
|
+
const cacheKey = message.cacheKey;
|
|
2648
|
+
if (cacheKey) {
|
|
2649
|
+
const cached = compileCache[cacheKey];
|
|
2650
|
+
if (cached) {
|
|
2651
|
+
return cached;
|
|
2652
|
+
}
|
|
2653
|
+
// compose message function from message (AST)
|
|
2654
|
+
return (compileCache[cacheKey] =
|
|
2655
|
+
format(message));
|
|
2656
|
+
}
|
|
2657
|
+
else {
|
|
2658
|
+
return format(message);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2586
2661
|
}
|
|
2587
2662
|
|
|
2588
2663
|
const NOOP_MESSAGE_FUNCTION = () => '';
|
|
@@ -3322,7 +3397,7 @@ function clearNumberFormat(ctx, locale, format) {
|
|
|
3322
3397
|
*
|
|
3323
3398
|
* @VueI18nGeneral
|
|
3324
3399
|
*/
|
|
3325
|
-
const VERSION = '9.
|
|
3400
|
+
const VERSION = '9.4.1';
|
|
3326
3401
|
/**
|
|
3327
3402
|
* This is only called development env
|
|
3328
3403
|
* istanbul-ignore-next
|
|
@@ -3361,7 +3436,7 @@ const warnMessages = {
|
|
|
3361
3436
|
[I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`
|
|
3362
3437
|
};
|
|
3363
3438
|
function getWarnMessage(code, ...args) {
|
|
3364
|
-
return format(warnMessages[code], ...args);
|
|
3439
|
+
return format$1(warnMessages[code], ...args);
|
|
3365
3440
|
}
|
|
3366
3441
|
|
|
3367
3442
|
const code = CoreErrorCodes.__EXTEND_POINT__;
|
|
@@ -5643,7 +5718,7 @@ function createI18n(options = {}, VueI18nLegacy) {
|
|
|
5643
5718
|
const [globalScope, __global] = createGlobal(options, __legacyMode);
|
|
5644
5719
|
const symbol = /* #__PURE__*/ makeSymbol('vue-i18n' );
|
|
5645
5720
|
{
|
|
5646
|
-
if (__legacyMode && __allowComposition) {
|
|
5721
|
+
if (__legacyMode && __allowComposition && !false) {
|
|
5647
5722
|
warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION));
|
|
5648
5723
|
}
|
|
5649
5724
|
}
|
|
@@ -6361,7 +6436,7 @@ function injectGlobalFields(app, composer) {
|
|
|
6361
6436
|
|
|
6362
6437
|
// register message compiler at vue-i18n
|
|
6363
6438
|
{
|
|
6364
|
-
registerMessageCompiler(
|
|
6439
|
+
registerMessageCompiler(compile);
|
|
6365
6440
|
}
|
|
6366
6441
|
// register message resolver at vue-i18n
|
|
6367
6442
|
registerMessageResolver(resolveValue);
|