vue-i18n 9.14.0 → 9.14.2
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/vue-i18n.cjs +16 -14
- package/dist/vue-i18n.esm-browser.js +147 -60
- package/dist/vue-i18n.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.global.js +147 -60
- package/dist/vue-i18n.global.prod.js +2 -2
- package/dist/vue-i18n.mjs +17 -15
- package/dist/vue-i18n.prod.cjs +16 -14
- package/dist/vue-i18n.runtime.esm-browser.js +67 -35
- package/dist/vue-i18n.runtime.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.runtime.global.js +67 -35
- package/dist/vue-i18n.runtime.global.prod.js +2 -2
- package/dist/vue-i18n.runtime.mjs +17 -15
- package/package.json +5 -5
package/dist/vue-i18n.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v9.14.
|
|
2
|
+
* vue-i18n v9.14.2
|
|
3
3
|
* (c) 2024 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.14.
|
|
20
|
+
const VERSION = '9.14.2';
|
|
21
21
|
|
|
22
22
|
const code$1 = coreBase.CoreWarnCodes.__EXTEND_POINT__;
|
|
23
23
|
const inc$1 = shared.incrementer(code$1);
|
|
@@ -142,7 +142,7 @@ function handleFlatJson(obj) {
|
|
|
142
142
|
let hasStringValue = false;
|
|
143
143
|
for (let i = 0; i < lastIndex; i++) {
|
|
144
144
|
if (!(subKeys[i] in currentObj)) {
|
|
145
|
-
currentObj[subKeys[i]] =
|
|
145
|
+
currentObj[subKeys[i]] = shared.create();
|
|
146
146
|
}
|
|
147
147
|
if (!shared.isObject(currentObj[subKeys[i]])) {
|
|
148
148
|
shared.warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, {
|
|
@@ -172,15 +172,15 @@ function getLocaleMessages(locale, options) {
|
|
|
172
172
|
const ret = (shared.isPlainObject(messages)
|
|
173
173
|
? messages
|
|
174
174
|
: shared.isArray(__i18n)
|
|
175
|
-
?
|
|
176
|
-
: { [locale]:
|
|
175
|
+
? shared.create()
|
|
176
|
+
: { [locale]: shared.create() });
|
|
177
177
|
// merge locale messages of i18n custom block
|
|
178
178
|
if (shared.isArray(__i18n)) {
|
|
179
179
|
__i18n.forEach(custom => {
|
|
180
180
|
if ('locale' in custom && 'resource' in custom) {
|
|
181
181
|
const { locale, resource } = custom;
|
|
182
182
|
if (locale) {
|
|
183
|
-
ret[locale] = ret[locale] ||
|
|
183
|
+
ret[locale] = ret[locale] || shared.create();
|
|
184
184
|
shared.deepCopy(resource, ret[locale]);
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
@@ -208,7 +208,9 @@ function getComponentOptions(instance) {
|
|
|
208
208
|
}
|
|
209
209
|
function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
210
210
|
) {
|
|
211
|
-
let messages = shared.isObject(options.messages)
|
|
211
|
+
let messages = shared.isObject(options.messages)
|
|
212
|
+
? options.messages
|
|
213
|
+
: shared.create();
|
|
212
214
|
if ('__i18nGlobal' in componentOptions) {
|
|
213
215
|
messages = getLocaleMessages(gl.locale.value, {
|
|
214
216
|
messages,
|
|
@@ -1245,7 +1247,7 @@ keys) {
|
|
|
1245
1247
|
arg[key] = slot();
|
|
1246
1248
|
}
|
|
1247
1249
|
return arg;
|
|
1248
|
-
},
|
|
1250
|
+
}, shared.create());
|
|
1249
1251
|
}
|
|
1250
1252
|
}
|
|
1251
1253
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1279,7 +1281,7 @@ const TranslationImpl = /*#__PURE__*/ vue.defineComponent({
|
|
|
1279
1281
|
});
|
|
1280
1282
|
return () => {
|
|
1281
1283
|
const keys = Object.keys(slots).filter(key => key !== '_');
|
|
1282
|
-
const options =
|
|
1284
|
+
const options = shared.create();
|
|
1283
1285
|
if (props.locale) {
|
|
1284
1286
|
options.locale = props.locale;
|
|
1285
1287
|
}
|
|
@@ -1289,7 +1291,7 @@ const TranslationImpl = /*#__PURE__*/ vue.defineComponent({
|
|
|
1289
1291
|
const arg = getInterpolateArg(context, keys);
|
|
1290
1292
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1291
1293
|
const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options);
|
|
1292
|
-
const assignedAttrs = shared.assign(
|
|
1294
|
+
const assignedAttrs = shared.assign(shared.create(), attrs);
|
|
1293
1295
|
const tag = shared.isString(props.tag) || shared.isObject(props.tag)
|
|
1294
1296
|
? props.tag
|
|
1295
1297
|
: getFragmentableTag();
|
|
@@ -1360,7 +1362,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
1360
1362
|
const { slots, attrs } = context;
|
|
1361
1363
|
return () => {
|
|
1362
1364
|
const options = { part: true };
|
|
1363
|
-
let overrides =
|
|
1365
|
+
let overrides = shared.create();
|
|
1364
1366
|
if (props.locale) {
|
|
1365
1367
|
options.locale = props.locale;
|
|
1366
1368
|
}
|
|
@@ -1376,9 +1378,9 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
1376
1378
|
// Filter out number format options only
|
|
1377
1379
|
overrides = Object.keys(props.format).reduce((options, prop) => {
|
|
1378
1380
|
return slotKeys.includes(prop)
|
|
1379
|
-
? shared.assign(
|
|
1381
|
+
? shared.assign(shared.create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1380
1382
|
: options;
|
|
1381
|
-
},
|
|
1383
|
+
}, shared.create());
|
|
1382
1384
|
}
|
|
1383
1385
|
const parts = partFormatter(...[props.value, options, overrides]);
|
|
1384
1386
|
let children = [options.key];
|
|
@@ -1397,7 +1399,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
1397
1399
|
else if (shared.isString(parts)) {
|
|
1398
1400
|
children = [parts];
|
|
1399
1401
|
}
|
|
1400
|
-
const assignedAttrs = shared.assign(
|
|
1402
|
+
const assignedAttrs = shared.assign(shared.create(), attrs);
|
|
1401
1403
|
const tag = shared.isString(props.tag) || shared.isObject(props.tag)
|
|
1402
1404
|
? props.tag
|
|
1403
1405
|
: getFragmentableTag();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v9.14.
|
|
2
|
+
* vue-i18n v9.14.2
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -54,6 +54,8 @@ const isDate = (val) => toTypeString(val) === '[object Date]';
|
|
|
54
54
|
const isRegExp = (val) => toTypeString(val) === '[object RegExp]';
|
|
55
55
|
const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0;
|
|
56
56
|
const assign = Object.assign;
|
|
57
|
+
const _create = Object.create;
|
|
58
|
+
const create = (obj = null) => _create(obj);
|
|
57
59
|
let _globalThis;
|
|
58
60
|
const getGlobalThis = () => {
|
|
59
61
|
// prettier-ignore
|
|
@@ -67,7 +69,7 @@ const getGlobalThis = () => {
|
|
|
67
69
|
? window
|
|
68
70
|
: typeof global !== 'undefined'
|
|
69
71
|
? global
|
|
70
|
-
:
|
|
72
|
+
: create()));
|
|
71
73
|
};
|
|
72
74
|
function escapeHtml(rawText) {
|
|
73
75
|
return rawText
|
|
@@ -223,8 +225,17 @@ function deepCopy(src, des) {
|
|
|
223
225
|
const stack = [{ src, des }];
|
|
224
226
|
while (stack.length) {
|
|
225
227
|
const { src, des } = stack.pop();
|
|
228
|
+
// using `Object.keys` which skips prototype properties
|
|
226
229
|
Object.keys(src).forEach(key => {
|
|
227
|
-
if (
|
|
230
|
+
if (key === '__proto__') {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// if src[key] is an object/array, set des[key]
|
|
234
|
+
// to empty object/array to prevent setting by reference
|
|
235
|
+
if (isObject(src[key]) && !isObject(des[key])) {
|
|
236
|
+
des[key] = Array.isArray(src[key]) ? [] : create();
|
|
237
|
+
}
|
|
238
|
+
if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) {
|
|
228
239
|
// replace with src[key] when:
|
|
229
240
|
// src[key] or des[key] is not an object, or
|
|
230
241
|
// src[key] or des[key] is an array
|
|
@@ -2061,7 +2072,7 @@ function resolveWithKeyValue(obj, path) {
|
|
|
2061
2072
|
*
|
|
2062
2073
|
* @VueI18nGeneral
|
|
2063
2074
|
*/
|
|
2064
|
-
function resolveValue(obj, path) {
|
|
2075
|
+
function resolveValue$1(obj, path) {
|
|
2065
2076
|
// check object
|
|
2066
2077
|
if (!isObject(obj)) {
|
|
2067
2078
|
return null;
|
|
@@ -2154,7 +2165,7 @@ function createMessageContext(options = {}) {
|
|
|
2154
2165
|
const _list = options.list || [];
|
|
2155
2166
|
const list = (index) => _list[index];
|
|
2156
2167
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2157
|
-
const _named = options.named ||
|
|
2168
|
+
const _named = options.named || create();
|
|
2158
2169
|
isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
|
|
2159
2170
|
const named = (key) => _named[key];
|
|
2160
2171
|
function message(key) {
|
|
@@ -2221,7 +2232,7 @@ function createMessageContext(options = {}) {
|
|
|
2221
2232
|
["type" /* HelperNameMap.TYPE */]: type,
|
|
2222
2233
|
["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate,
|
|
2223
2234
|
["normalize" /* HelperNameMap.NORMALIZE */]: normalize,
|
|
2224
|
-
["values" /* HelperNameMap.VALUES */]: assign(
|
|
2235
|
+
["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named)
|
|
2225
2236
|
};
|
|
2226
2237
|
return ctx;
|
|
2227
2238
|
}
|
|
@@ -2452,7 +2463,7 @@ function appendItemToChain(chain, target, blocks) {
|
|
|
2452
2463
|
* Intlify core-base version
|
|
2453
2464
|
* @internal
|
|
2454
2465
|
*/
|
|
2455
|
-
const VERSION$1 = '9.14.
|
|
2466
|
+
const VERSION$1 = '9.14.2';
|
|
2456
2467
|
const NOT_REOSLVED = -1;
|
|
2457
2468
|
const DEFAULT_LOCALE = 'en-US';
|
|
2458
2469
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -2542,17 +2553,17 @@ function createCoreContext(options = {}) {
|
|
|
2542
2553
|
: _locale;
|
|
2543
2554
|
const messages = isPlainObject(options.messages)
|
|
2544
2555
|
? options.messages
|
|
2545
|
-
:
|
|
2556
|
+
: createResources(_locale);
|
|
2546
2557
|
const datetimeFormats = isPlainObject(options.datetimeFormats)
|
|
2547
2558
|
? options.datetimeFormats
|
|
2548
|
-
:
|
|
2559
|
+
: createResources(_locale)
|
|
2549
2560
|
;
|
|
2550
2561
|
const numberFormats = isPlainObject(options.numberFormats)
|
|
2551
2562
|
? options.numberFormats
|
|
2552
|
-
:
|
|
2563
|
+
: createResources(_locale)
|
|
2553
2564
|
;
|
|
2554
|
-
const modifiers = assign(
|
|
2555
|
-
const pluralRules = options.pluralRules ||
|
|
2565
|
+
const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers());
|
|
2566
|
+
const pluralRules = options.pluralRules || create();
|
|
2556
2567
|
const missing = isFunction(options.missing) ? options.missing : null;
|
|
2557
2568
|
const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
|
|
2558
2569
|
? options.missingWarn
|
|
@@ -2640,6 +2651,7 @@ function createCoreContext(options = {}) {
|
|
|
2640
2651
|
}
|
|
2641
2652
|
return context;
|
|
2642
2653
|
}
|
|
2654
|
+
const createResources = (locale) => ({ [locale]: create() });
|
|
2643
2655
|
/** @internal */
|
|
2644
2656
|
function isTranslateFallbackWarn(fallback, key) {
|
|
2645
2657
|
return fallback instanceof RegExp ? fallback.test(key) : fallback;
|
|
@@ -2706,10 +2718,14 @@ function format(ast) {
|
|
|
2706
2718
|
return msg;
|
|
2707
2719
|
}
|
|
2708
2720
|
function formatParts(ctx, ast) {
|
|
2709
|
-
const body = ast
|
|
2710
|
-
if (
|
|
2721
|
+
const body = resolveBody(ast);
|
|
2722
|
+
if (body == null) {
|
|
2723
|
+
throw createUnhandleNodeError(0 /* NodeTypes.Resource */);
|
|
2724
|
+
}
|
|
2725
|
+
const type = resolveType(body);
|
|
2726
|
+
if (type === 1 /* NodeTypes.Plural */) {
|
|
2711
2727
|
const plural = body;
|
|
2712
|
-
const cases = plural
|
|
2728
|
+
const cases = resolveCases(plural);
|
|
2713
2729
|
return ctx.plural(cases.reduce((messages, c) => [
|
|
2714
2730
|
...messages,
|
|
2715
2731
|
formatMessageParts(ctx, c)
|
|
@@ -2719,54 +2735,121 @@ function formatParts(ctx, ast) {
|
|
|
2719
2735
|
return formatMessageParts(ctx, body);
|
|
2720
2736
|
}
|
|
2721
2737
|
}
|
|
2738
|
+
const PROPS_BODY = ['b', 'body'];
|
|
2739
|
+
function resolveBody(node) {
|
|
2740
|
+
return resolveProps(node, PROPS_BODY);
|
|
2741
|
+
}
|
|
2742
|
+
const PROPS_CASES = ['c', 'cases'];
|
|
2743
|
+
function resolveCases(node) {
|
|
2744
|
+
return resolveProps(node, PROPS_CASES, []);
|
|
2745
|
+
}
|
|
2722
2746
|
function formatMessageParts(ctx, node) {
|
|
2723
|
-
const
|
|
2724
|
-
if (
|
|
2747
|
+
const static_ = resolveStatic(node);
|
|
2748
|
+
if (static_ != null) {
|
|
2725
2749
|
return ctx.type === 'text'
|
|
2726
|
-
?
|
|
2727
|
-
: ctx.normalize([
|
|
2750
|
+
? static_
|
|
2751
|
+
: ctx.normalize([static_]);
|
|
2728
2752
|
}
|
|
2729
2753
|
else {
|
|
2730
|
-
const messages = (node
|
|
2754
|
+
const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []);
|
|
2731
2755
|
return ctx.normalize(messages);
|
|
2732
2756
|
}
|
|
2733
2757
|
}
|
|
2758
|
+
const PROPS_STATIC = ['s', 'static'];
|
|
2759
|
+
function resolveStatic(node) {
|
|
2760
|
+
return resolveProps(node, PROPS_STATIC);
|
|
2761
|
+
}
|
|
2762
|
+
const PROPS_ITEMS = ['i', 'items'];
|
|
2763
|
+
function resolveItems(node) {
|
|
2764
|
+
return resolveProps(node, PROPS_ITEMS, []);
|
|
2765
|
+
}
|
|
2734
2766
|
function formatMessagePart(ctx, node) {
|
|
2735
|
-
const type = node
|
|
2767
|
+
const type = resolveType(node);
|
|
2736
2768
|
switch (type) {
|
|
2737
2769
|
case 3 /* NodeTypes.Text */: {
|
|
2738
|
-
|
|
2739
|
-
return (text.v || text.value);
|
|
2770
|
+
return resolveValue(node, type);
|
|
2740
2771
|
}
|
|
2741
2772
|
case 9 /* NodeTypes.Literal */: {
|
|
2742
|
-
|
|
2743
|
-
return (literal.v || literal.value);
|
|
2773
|
+
return resolveValue(node, type);
|
|
2744
2774
|
}
|
|
2745
2775
|
case 4 /* NodeTypes.Named */: {
|
|
2746
2776
|
const named = node;
|
|
2747
|
-
|
|
2777
|
+
if (hasOwn(named, 'k') && named.k) {
|
|
2778
|
+
return ctx.interpolate(ctx.named(named.k));
|
|
2779
|
+
}
|
|
2780
|
+
if (hasOwn(named, 'key') && named.key) {
|
|
2781
|
+
return ctx.interpolate(ctx.named(named.key));
|
|
2782
|
+
}
|
|
2783
|
+
throw createUnhandleNodeError(type);
|
|
2748
2784
|
}
|
|
2749
2785
|
case 5 /* NodeTypes.List */: {
|
|
2750
2786
|
const list = node;
|
|
2751
|
-
|
|
2787
|
+
if (hasOwn(list, 'i') && isNumber(list.i)) {
|
|
2788
|
+
return ctx.interpolate(ctx.list(list.i));
|
|
2789
|
+
}
|
|
2790
|
+
if (hasOwn(list, 'index') && isNumber(list.index)) {
|
|
2791
|
+
return ctx.interpolate(ctx.list(list.index));
|
|
2792
|
+
}
|
|
2793
|
+
throw createUnhandleNodeError(type);
|
|
2752
2794
|
}
|
|
2753
2795
|
case 6 /* NodeTypes.Linked */: {
|
|
2754
2796
|
const linked = node;
|
|
2755
|
-
const modifier = linked
|
|
2756
|
-
|
|
2797
|
+
const modifier = resolveLinkedModifier(linked);
|
|
2798
|
+
const key = resolveLinkedKey(linked);
|
|
2799
|
+
return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type);
|
|
2757
2800
|
}
|
|
2758
2801
|
case 7 /* NodeTypes.LinkedKey */: {
|
|
2759
|
-
|
|
2760
|
-
return (linkedKey.v || linkedKey.value);
|
|
2802
|
+
return resolveValue(node, type);
|
|
2761
2803
|
}
|
|
2762
2804
|
case 8 /* NodeTypes.LinkedModifier */: {
|
|
2763
|
-
|
|
2764
|
-
return (linkedModifier.v || linkedModifier.value);
|
|
2805
|
+
return resolveValue(node, type);
|
|
2765
2806
|
}
|
|
2766
2807
|
default:
|
|
2767
|
-
throw new Error(`unhandled node
|
|
2808
|
+
throw new Error(`unhandled node on format message part: ${type}`);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
const PROPS_TYPE = ['t', 'type'];
|
|
2812
|
+
function resolveType(node) {
|
|
2813
|
+
return resolveProps(node, PROPS_TYPE);
|
|
2814
|
+
}
|
|
2815
|
+
const PROPS_VALUE = ['v', 'value'];
|
|
2816
|
+
function resolveValue(node, type) {
|
|
2817
|
+
const resolved = resolveProps(node, PROPS_VALUE);
|
|
2818
|
+
if (resolved) {
|
|
2819
|
+
return resolved;
|
|
2820
|
+
}
|
|
2821
|
+
else {
|
|
2822
|
+
throw createUnhandleNodeError(type);
|
|
2768
2823
|
}
|
|
2769
2824
|
}
|
|
2825
|
+
const PROPS_MODIFIER = ['m', 'modifier'];
|
|
2826
|
+
function resolveLinkedModifier(node) {
|
|
2827
|
+
return resolveProps(node, PROPS_MODIFIER);
|
|
2828
|
+
}
|
|
2829
|
+
const PROPS_KEY = ['k', 'key'];
|
|
2830
|
+
function resolveLinkedKey(node) {
|
|
2831
|
+
const resolved = resolveProps(node, PROPS_KEY);
|
|
2832
|
+
if (resolved) {
|
|
2833
|
+
return resolved;
|
|
2834
|
+
}
|
|
2835
|
+
else {
|
|
2836
|
+
throw createUnhandleNodeError(6 /* NodeTypes.Linked */);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
function resolveProps(node, props, defaultValue) {
|
|
2840
|
+
for (let i = 0; i < props.length; i++) {
|
|
2841
|
+
const prop = props[i];
|
|
2842
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2843
|
+
if (hasOwn(node, prop) && node[prop] != null) {
|
|
2844
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2845
|
+
return node[prop];
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
return defaultValue;
|
|
2849
|
+
}
|
|
2850
|
+
function createUnhandleNodeError(type) {
|
|
2851
|
+
return new Error(`unhandled node type: ${type}`);
|
|
2852
|
+
}
|
|
2770
2853
|
|
|
2771
2854
|
const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`;
|
|
2772
2855
|
function checkHtmlMessage(source, warnHtmlMessage) {
|
|
@@ -2775,7 +2858,7 @@ function checkHtmlMessage(source, warnHtmlMessage) {
|
|
|
2775
2858
|
}
|
|
2776
2859
|
}
|
|
2777
2860
|
const defaultOnCacheKey = (message) => message;
|
|
2778
|
-
let compileCache =
|
|
2861
|
+
let compileCache = create();
|
|
2779
2862
|
function onCompileWarn(_warn) {
|
|
2780
2863
|
if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) {
|
|
2781
2864
|
warn(`The use of named interpolation with modulo syntax is deprecated. ` +
|
|
@@ -2784,9 +2867,11 @@ function onCompileWarn(_warn) {
|
|
|
2784
2867
|
`(message compiler warning message: ${_warn.message})`);
|
|
2785
2868
|
}
|
|
2786
2869
|
}
|
|
2787
|
-
|
|
2788
|
-
(val
|
|
2789
|
-
|
|
2870
|
+
function isMessageAST(val) {
|
|
2871
|
+
return (isObject(val) &&
|
|
2872
|
+
resolveType(val) === 0 &&
|
|
2873
|
+
(hasOwn(val, 'b') || hasOwn(val, 'body')));
|
|
2874
|
+
}
|
|
2790
2875
|
function baseCompile(message, options = {}) {
|
|
2791
2876
|
// error detecting on compile
|
|
2792
2877
|
let detectError = false;
|
|
@@ -2886,7 +2971,7 @@ function translate(context, ...args) {
|
|
|
2886
2971
|
: [
|
|
2887
2972
|
key,
|
|
2888
2973
|
locale,
|
|
2889
|
-
messages[locale] ||
|
|
2974
|
+
messages[locale] || create()
|
|
2890
2975
|
];
|
|
2891
2976
|
// NOTE:
|
|
2892
2977
|
// Fix to work around `ssrTransfrom` bug in Vite.
|
|
@@ -2982,7 +3067,7 @@ function escapeParams(options) {
|
|
|
2982
3067
|
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
2983
3068
|
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
2984
3069
|
const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2985
|
-
let message =
|
|
3070
|
+
let message = create();
|
|
2986
3071
|
let targetLocale;
|
|
2987
3072
|
let format = null;
|
|
2988
3073
|
let from = locale;
|
|
@@ -3012,7 +3097,7 @@ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn
|
|
|
3012
3097
|
}
|
|
3013
3098
|
}
|
|
3014
3099
|
message =
|
|
3015
|
-
messages[targetLocale] ||
|
|
3100
|
+
messages[targetLocale] || create();
|
|
3016
3101
|
// for vue-devtools timeline event
|
|
3017
3102
|
let start = null;
|
|
3018
3103
|
let startTag;
|
|
@@ -3140,7 +3225,7 @@ function evaluateMessage(context, msg, msgCtx) {
|
|
|
3140
3225
|
/** @internal */
|
|
3141
3226
|
function parseTranslateArgs(...args) {
|
|
3142
3227
|
const [arg1, arg2, arg3] = args;
|
|
3143
|
-
const options =
|
|
3228
|
+
const options = create();
|
|
3144
3229
|
if (!isString(arg1) &&
|
|
3145
3230
|
!isNumber(arg1) &&
|
|
3146
3231
|
!isMessageFunction(arg1) &&
|
|
@@ -3369,8 +3454,8 @@ const DATETIME_FORMAT_OPTIONS_KEYS = [
|
|
|
3369
3454
|
/** @internal */
|
|
3370
3455
|
function parseDateTimeArgs(...args) {
|
|
3371
3456
|
const [arg1, arg2, arg3, arg4] = args;
|
|
3372
|
-
const options =
|
|
3373
|
-
let overrides =
|
|
3457
|
+
const options = create();
|
|
3458
|
+
let overrides = create();
|
|
3374
3459
|
let value;
|
|
3375
3460
|
if (isString(arg1)) {
|
|
3376
3461
|
// Only allow ISO strings - other date formats are often supported,
|
|
@@ -3543,8 +3628,8 @@ const NUMBER_FORMAT_OPTIONS_KEYS = [
|
|
|
3543
3628
|
/** @internal */
|
|
3544
3629
|
function parseNumberArgs(...args) {
|
|
3545
3630
|
const [arg1, arg2, arg3, arg4] = args;
|
|
3546
|
-
const options =
|
|
3547
|
-
let overrides =
|
|
3631
|
+
const options = create();
|
|
3632
|
+
let overrides = create();
|
|
3548
3633
|
if (!isNumber(arg1)) {
|
|
3549
3634
|
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
3550
3635
|
}
|
|
@@ -3593,7 +3678,7 @@ function clearNumberFormat(ctx, locale, format) {
|
|
|
3593
3678
|
*
|
|
3594
3679
|
* @VueI18nGeneral
|
|
3595
3680
|
*/
|
|
3596
|
-
const VERSION = '9.14.
|
|
3681
|
+
const VERSION = '9.14.2';
|
|
3597
3682
|
/**
|
|
3598
3683
|
* This is only called development env
|
|
3599
3684
|
* istanbul-ignore-next
|
|
@@ -3729,7 +3814,7 @@ function handleFlatJson(obj) {
|
|
|
3729
3814
|
let hasStringValue = false;
|
|
3730
3815
|
for (let i = 0; i < lastIndex; i++) {
|
|
3731
3816
|
if (!(subKeys[i] in currentObj)) {
|
|
3732
|
-
currentObj[subKeys[i]] =
|
|
3817
|
+
currentObj[subKeys[i]] = create();
|
|
3733
3818
|
}
|
|
3734
3819
|
if (!isObject(currentObj[subKeys[i]])) {
|
|
3735
3820
|
warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, {
|
|
@@ -3759,15 +3844,15 @@ function getLocaleMessages(locale, options) {
|
|
|
3759
3844
|
const ret = (isPlainObject(messages)
|
|
3760
3845
|
? messages
|
|
3761
3846
|
: isArray(__i18n)
|
|
3762
|
-
?
|
|
3763
|
-
: { [locale]:
|
|
3847
|
+
? create()
|
|
3848
|
+
: { [locale]: create() });
|
|
3764
3849
|
// merge locale messages of i18n custom block
|
|
3765
3850
|
if (isArray(__i18n)) {
|
|
3766
3851
|
__i18n.forEach(custom => {
|
|
3767
3852
|
if ('locale' in custom && 'resource' in custom) {
|
|
3768
3853
|
const { locale, resource } = custom;
|
|
3769
3854
|
if (locale) {
|
|
3770
|
-
ret[locale] = ret[locale] ||
|
|
3855
|
+
ret[locale] = ret[locale] || create();
|
|
3771
3856
|
deepCopy(resource, ret[locale]);
|
|
3772
3857
|
}
|
|
3773
3858
|
else {
|
|
@@ -3795,7 +3880,9 @@ function getComponentOptions(instance) {
|
|
|
3795
3880
|
}
|
|
3796
3881
|
function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
3797
3882
|
) {
|
|
3798
|
-
let messages = isObject(options.messages)
|
|
3883
|
+
let messages = isObject(options.messages)
|
|
3884
|
+
? options.messages
|
|
3885
|
+
: create();
|
|
3799
3886
|
if ('__i18nGlobal' in componentOptions) {
|
|
3800
3887
|
messages = getLocaleMessages(gl.locale.value, {
|
|
3801
3888
|
messages,
|
|
@@ -4829,7 +4916,7 @@ keys) {
|
|
|
4829
4916
|
arg[key] = slot();
|
|
4830
4917
|
}
|
|
4831
4918
|
return arg;
|
|
4832
|
-
},
|
|
4919
|
+
}, create());
|
|
4833
4920
|
}
|
|
4834
4921
|
}
|
|
4835
4922
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -4863,7 +4950,7 @@ const TranslationImpl = /*#__PURE__*/ defineComponent({
|
|
|
4863
4950
|
});
|
|
4864
4951
|
return () => {
|
|
4865
4952
|
const keys = Object.keys(slots).filter(key => key !== '_');
|
|
4866
|
-
const options =
|
|
4953
|
+
const options = create();
|
|
4867
4954
|
if (props.locale) {
|
|
4868
4955
|
options.locale = props.locale;
|
|
4869
4956
|
}
|
|
@@ -4873,7 +4960,7 @@ const TranslationImpl = /*#__PURE__*/ defineComponent({
|
|
|
4873
4960
|
const arg = getInterpolateArg(context, keys);
|
|
4874
4961
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4875
4962
|
const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options);
|
|
4876
|
-
const assignedAttrs = assign(
|
|
4963
|
+
const assignedAttrs = assign(create(), attrs);
|
|
4877
4964
|
const tag = isString(props.tag) || isObject(props.tag)
|
|
4878
4965
|
? props.tag
|
|
4879
4966
|
: getFragmentableTag();
|
|
@@ -4944,7 +5031,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
4944
5031
|
const { slots, attrs } = context;
|
|
4945
5032
|
return () => {
|
|
4946
5033
|
const options = { part: true };
|
|
4947
|
-
let overrides =
|
|
5034
|
+
let overrides = create();
|
|
4948
5035
|
if (props.locale) {
|
|
4949
5036
|
options.locale = props.locale;
|
|
4950
5037
|
}
|
|
@@ -4960,9 +5047,9 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
4960
5047
|
// Filter out number format options only
|
|
4961
5048
|
overrides = Object.keys(props.format).reduce((options, prop) => {
|
|
4962
5049
|
return slotKeys.includes(prop)
|
|
4963
|
-
? assign(
|
|
5050
|
+
? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4964
5051
|
: options;
|
|
4965
|
-
},
|
|
5052
|
+
}, create());
|
|
4966
5053
|
}
|
|
4967
5054
|
const parts = partFormatter(...[props.value, options, overrides]);
|
|
4968
5055
|
let children = [options.key];
|
|
@@ -4981,7 +5068,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
|
|
|
4981
5068
|
else if (isString(parts)) {
|
|
4982
5069
|
children = [parts];
|
|
4983
5070
|
}
|
|
4984
|
-
const assignedAttrs = assign(
|
|
5071
|
+
const assignedAttrs = assign(create(), attrs);
|
|
4985
5072
|
const tag = isString(props.tag) || isObject(props.tag)
|
|
4986
5073
|
? props.tag
|
|
4987
5074
|
: getFragmentableTag();
|
|
@@ -6661,7 +6748,7 @@ function injectGlobalFields(app, composer) {
|
|
|
6661
6748
|
registerMessageCompiler(compile);
|
|
6662
6749
|
}
|
|
6663
6750
|
// register message resolver at vue-i18n
|
|
6664
|
-
registerMessageResolver(resolveValue);
|
|
6751
|
+
registerMessageResolver(resolveValue$1);
|
|
6665
6752
|
// register fallback locale at vue-i18n
|
|
6666
6753
|
registerLocaleFallbacker(fallbackWithLocaleChain);
|
|
6667
6754
|
// NOTE: experimental !!
|