vue-i18n 9.2.0-beta.21 → 9.2.0-beta.25

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v9.2.0-beta.21
2
+ * vue-i18n v9.2.0-beta.25
3
3
  * (c) 2021 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -19,7 +19,7 @@ var vue = require('vue');
19
19
  *
20
20
  * @VueI18nGeneral
21
21
  */
22
- const VERSION = '9.2.0-beta.21';
22
+ const VERSION = '9.2.0-beta.25';
23
23
 
24
24
  let code$1 = coreBase.CoreWarnCodes.__EXTEND_POINT__;
25
25
  const inc$1 = () => code$1++;
@@ -244,9 +244,14 @@ function adjustI18nResources(global, options, componentOptions // eslint-disable
244
244
  }
245
245
  }
246
246
  }
247
+ function createTextNode(key) {
248
+ return vue.createVNode(vue.Text, null, key, 0)
249
+ ;
250
+ }
247
251
  /* eslint-enable @typescript-eslint/no-explicit-any */
248
252
 
249
253
  /* eslint-disable @typescript-eslint/no-explicit-any */
254
+ // extend VNode interface
250
255
  const DEVTOOLS_META = '__INTLIFY_META__';
251
256
  let composerID = 0;
252
257
  function defineCoreMissingHandler(missing) {
@@ -518,7 +523,7 @@ function createComposer(options = {}, VueI18nLegacy) {
518
523
  }
519
524
  // for custom processor
520
525
  function normalize(values) {
521
- return values.map(val => shared.isString(val) ? vue.createVNode(vue.Text, null, val, 0) : val);
526
+ return values.map(val => (shared.isString(val) ? createTextNode(val) : val));
522
527
  }
523
528
  const interpolate = (val) => val;
524
529
  const processor = {
@@ -541,7 +546,7 @@ function createComposer(options = {}, VueI18nLegacy) {
541
546
  return ret;
542
547
  }, () => coreBase.parseTranslateArgs(...args), 'translate',
543
548
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
544
- root => root[TransrateVNodeSymbol](...args), key => [vue.createVNode(vue.Text, null, key, 0)], val => shared.isArray(val));
549
+ root => root[TransrateVNodeSymbol](...args), key => [createTextNode(key)], val => shared.isArray(val));
545
550
  }
546
551
  // numberParts, using for `i18n-n` component
547
552
  function numberParts(...args) {
@@ -749,11 +754,9 @@ function createComposer(options = {}, VueI18nLegacy) {
749
754
  composer.setNumberFormat = setNumberFormat;
750
755
  composer.mergeNumberFormat = mergeNumberFormat;
751
756
  composer[InejctWithOption] = options.__injectWithOption;
752
- {
753
- composer[TransrateVNodeSymbol] = transrateVNode;
754
- composer[NumberPartsSymbol] = numberParts;
755
- composer[DatetimePartsSymbol] = datetimeParts;
756
- }
757
+ composer[TransrateVNodeSymbol] = transrateVNode;
758
+ composer[DatetimePartsSymbol] = datetimeParts;
759
+ composer[NumberPartsSymbol] = numberParts;
757
760
  }
758
761
  // for vue-devtools timeline event
759
762
  {
@@ -1156,6 +1159,37 @@ const baseFormatProps = {
1156
1159
  }
1157
1160
  };
1158
1161
 
1162
+ function getInterpolateArg(
1163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1164
+ { slots }, // SetupContext,
1165
+ keys) {
1166
+ if (keys.length === 1 && keys[0] === 'default') {
1167
+ // default slot with list
1168
+ const ret = slots.default ? slots.default() : [];
1169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1170
+ return ret.reduce((slot, current) => {
1171
+ return (slot = [
1172
+ ...slot,
1173
+ ...(shared.isArray(current.children) ? current.children : [current])
1174
+ ]);
1175
+ }, []);
1176
+ }
1177
+ else {
1178
+ // named slots
1179
+ return keys.reduce((arg, key) => {
1180
+ const slot = slots[key];
1181
+ if (slot) {
1182
+ arg[key] = slot();
1183
+ }
1184
+ return arg;
1185
+ }, {});
1186
+ }
1187
+ }
1188
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1189
+ function getFragmentableTag(tag) {
1190
+ return vue.Fragment ;
1191
+ }
1192
+
1159
1193
  /**
1160
1194
  * Translation Component
1161
1195
  *
@@ -1205,7 +1239,7 @@ const baseFormatProps = {
1205
1239
  *
1206
1240
  * @VueI18nComponent
1207
1241
  */
1208
- const Translation = /* #__PURE__*/ vue.defineComponent({
1242
+ const Translation = /* defineComponent */ {
1209
1243
  /* eslint-disable */
1210
1244
  name: 'i18n-t',
1211
1245
  props: shared.assign({
@@ -1220,6 +1254,7 @@ const Translation = /* #__PURE__*/ vue.defineComponent({
1220
1254
  }
1221
1255
  }, baseFormatProps),
1222
1256
  /* eslint-enable */
1257
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1223
1258
  setup(props, context) {
1224
1259
  const { slots, attrs } = context;
1225
1260
  // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050
@@ -1241,27 +1276,13 @@ const Translation = /* #__PURE__*/ vue.defineComponent({
1241
1276
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1242
1277
  const children = i18n[TransrateVNodeSymbol](props.keypath, arg, options);
1243
1278
  const assignedAttrs = shared.assign({}, attrs);
1244
- const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : vue.Fragment;
1279
+ const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1280
+ ? props.tag
1281
+ : getFragmentableTag();
1245
1282
  return vue.h(tag, assignedAttrs, children);
1246
1283
  };
1247
1284
  }
1248
- });
1249
- function getInterpolateArg({ slots }, keys) {
1250
- if (keys.length === 1 && keys[0] === 'default') {
1251
- // default slot only
1252
- return slots.default ? slots.default() : [];
1253
- }
1254
- else {
1255
- // named slots
1256
- return keys.reduce((arg, key) => {
1257
- const slot = slots[key];
1258
- if (slot) {
1259
- arg[key] = slot();
1260
- }
1261
- return arg;
1262
- }, {});
1263
- }
1264
- }
1285
+ };
1265
1286
 
1266
1287
  function renderFormatter(props, context, slotKeys, partFormatter) {
1267
1288
  const { slots, attrs } = context;
@@ -1301,7 +1322,9 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
1301
1322
  children = [parts];
1302
1323
  }
1303
1324
  const assignedAttrs = shared.assign({}, attrs);
1304
- const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : vue.Fragment;
1325
+ const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1326
+ ? props.tag
1327
+ : getFragmentableTag();
1305
1328
  return vue.h(tag, assignedAttrs, children);
1306
1329
  };
1307
1330
  }
@@ -1340,7 +1363,7 @@ const NUMBER_FORMAT_KEYS = [
1340
1363
  *
1341
1364
  * @VueI18nComponent
1342
1365
  */
1343
- const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1366
+ const NumberFormat = /* defineComponent */ {
1344
1367
  /* eslint-disable */
1345
1368
  name: 'i18n-n',
1346
1369
  props: shared.assign({
@@ -1353,6 +1376,7 @@ const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1353
1376
  }
1354
1377
  }, baseFormatProps),
1355
1378
  /* eslint-enable */
1379
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1356
1380
  setup(props, context) {
1357
1381
  const i18n = props.i18n ||
1358
1382
  useI18n({ useScope: 'parent', __useComponent: true });
@@ -1360,7 +1384,7 @@ const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1360
1384
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1361
1385
  i18n[NumberPartsSymbol](...args));
1362
1386
  }
1363
- });
1387
+ };
1364
1388
 
1365
1389
  const DATETIME_FORMAT_KEYS = [
1366
1390
  'dateStyle',
@@ -1401,7 +1425,7 @@ const DATETIME_FORMAT_KEYS = [
1401
1425
  *
1402
1426
  * @VueI18nComponent
1403
1427
  */
1404
- const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1428
+ const DatetimeFormat = /*defineComponent */ {
1405
1429
  /* eslint-disable */
1406
1430
  name: 'i18n-d',
1407
1431
  props: shared.assign({
@@ -1414,6 +1438,7 @@ const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1414
1438
  }
1415
1439
  }, baseFormatProps),
1416
1440
  /* eslint-enable */
1441
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1417
1442
  setup(props, context) {
1418
1443
  const i18n = props.i18n ||
1419
1444
  useI18n({ useScope: 'parent', __useComponent: true });
@@ -1421,7 +1446,7 @@ const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1421
1446
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1422
1447
  i18n[DatetimePartsSymbol](...args));
1423
1448
  }
1424
- });
1449
+ };
1425
1450
 
1426
1451
  function getComposer$1(i18n, instance) {
1427
1452
  const i18nInternal = i18n;
@@ -1663,10 +1688,8 @@ function createI18n(options = {}, VueI18nLegacy) {
1663
1688
  // install plugin
1664
1689
  async install(app, ...options) {
1665
1690
  // setup global provider
1666
- {
1667
- app.__VUE_I18N_SYMBOL__ = symbol;
1668
- app.provide(app.__VUE_I18N_SYMBOL__, i18n);
1669
- }
1691
+ app.__VUE_I18N_SYMBOL__ = symbol;
1692
+ app.provide(app.__VUE_I18N_SYMBOL__, i18n);
1670
1693
  // global method and properties injection for Composition API
1671
1694
  if (!__legacyMode && __globalInjection) {
1672
1695
  injectGlobalFields(app, i18n.global);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v9.2.0-beta.21
2
+ * vue-i18n v9.2.0-beta.25
3
3
  * (c) 2021 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -19,7 +19,7 @@ var shared = require('@intlify/shared');
19
19
  *
20
20
  * @VueI18nGeneral
21
21
  */
22
- const VERSION = '9.2.0-beta.21';
22
+ const VERSION = '9.2.0-beta.25';
23
23
 
24
24
  let code = coreBase.CompileErrorCodes.__EXTEND_POINT__;
25
25
  const inc = () => code++;
@@ -202,6 +202,10 @@ function adjustI18nResources(global, options, componentOptions // eslint-disable
202
202
  }
203
203
  }
204
204
  }
205
+ function createTextNode(key) {
206
+ return vue.createVNode(vue.Text, null, key, 0)
207
+ ;
208
+ }
205
209
  /* eslint-enable @typescript-eslint/no-explicit-any */
206
210
 
207
211
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -428,7 +432,7 @@ function createComposer(options = {}, VueI18nLegacy) {
428
432
  }
429
433
  // for custom processor
430
434
  function normalize(values) {
431
- return values.map(val => shared.isString(val) ? vue.createVNode(vue.Text, null, val, 0) : val);
435
+ return values.map(val => (shared.isString(val) ? createTextNode(val) : val));
432
436
  }
433
437
  const interpolate = (val) => val;
434
438
  const processor = {
@@ -451,7 +455,7 @@ function createComposer(options = {}, VueI18nLegacy) {
451
455
  return ret;
452
456
  }, () => coreBase.parseTranslateArgs(...args), 'translate',
453
457
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
454
- root => root[TransrateVNodeSymbol](...args), key => [vue.createVNode(vue.Text, null, key, 0)], val => shared.isArray(val));
458
+ root => root[TransrateVNodeSymbol](...args), key => [createTextNode(key)], val => shared.isArray(val));
455
459
  }
456
460
  // numberParts, using for `i18n-n` component
457
461
  function numberParts(...args) {
@@ -659,11 +663,9 @@ function createComposer(options = {}, VueI18nLegacy) {
659
663
  composer.setNumberFormat = setNumberFormat;
660
664
  composer.mergeNumberFormat = mergeNumberFormat;
661
665
  composer[InejctWithOption] = options.__injectWithOption;
662
- {
663
- composer[TransrateVNodeSymbol] = transrateVNode;
664
- composer[NumberPartsSymbol] = numberParts;
665
- composer[DatetimePartsSymbol] = datetimeParts;
666
- }
666
+ composer[TransrateVNodeSymbol] = transrateVNode;
667
+ composer[DatetimePartsSymbol] = datetimeParts;
668
+ composer[NumberPartsSymbol] = numberParts;
667
669
  }
668
670
  return composer;
669
671
  }
@@ -1035,6 +1037,37 @@ const baseFormatProps = {
1035
1037
  }
1036
1038
  };
1037
1039
 
1040
+ function getInterpolateArg(
1041
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1042
+ { slots }, // SetupContext,
1043
+ keys) {
1044
+ if (keys.length === 1 && keys[0] === 'default') {
1045
+ // default slot with list
1046
+ const ret = slots.default ? slots.default() : [];
1047
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1048
+ return ret.reduce((slot, current) => {
1049
+ return (slot = [
1050
+ ...slot,
1051
+ ...(shared.isArray(current.children) ? current.children : [current])
1052
+ ]);
1053
+ }, []);
1054
+ }
1055
+ else {
1056
+ // named slots
1057
+ return keys.reduce((arg, key) => {
1058
+ const slot = slots[key];
1059
+ if (slot) {
1060
+ arg[key] = slot();
1061
+ }
1062
+ return arg;
1063
+ }, {});
1064
+ }
1065
+ }
1066
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1067
+ function getFragmentableTag(tag) {
1068
+ return vue.Fragment ;
1069
+ }
1070
+
1038
1071
  /**
1039
1072
  * Translation Component
1040
1073
  *
@@ -1084,7 +1117,7 @@ const baseFormatProps = {
1084
1117
  *
1085
1118
  * @VueI18nComponent
1086
1119
  */
1087
- const Translation = /* #__PURE__*/ vue.defineComponent({
1120
+ const Translation = /* defineComponent */ {
1088
1121
  /* eslint-disable */
1089
1122
  name: 'i18n-t',
1090
1123
  props: shared.assign({
@@ -1099,6 +1132,7 @@ const Translation = /* #__PURE__*/ vue.defineComponent({
1099
1132
  }
1100
1133
  }, baseFormatProps),
1101
1134
  /* eslint-enable */
1135
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1102
1136
  setup(props, context) {
1103
1137
  const { slots, attrs } = context;
1104
1138
  // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050
@@ -1120,27 +1154,13 @@ const Translation = /* #__PURE__*/ vue.defineComponent({
1120
1154
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1121
1155
  const children = i18n[TransrateVNodeSymbol](props.keypath, arg, options);
1122
1156
  const assignedAttrs = shared.assign({}, attrs);
1123
- const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : vue.Fragment;
1157
+ const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1158
+ ? props.tag
1159
+ : getFragmentableTag();
1124
1160
  return vue.h(tag, assignedAttrs, children);
1125
1161
  };
1126
1162
  }
1127
- });
1128
- function getInterpolateArg({ slots }, keys) {
1129
- if (keys.length === 1 && keys[0] === 'default') {
1130
- // default slot only
1131
- return slots.default ? slots.default() : [];
1132
- }
1133
- else {
1134
- // named slots
1135
- return keys.reduce((arg, key) => {
1136
- const slot = slots[key];
1137
- if (slot) {
1138
- arg[key] = slot();
1139
- }
1140
- return arg;
1141
- }, {});
1142
- }
1143
- }
1163
+ };
1144
1164
 
1145
1165
  function renderFormatter(props, context, slotKeys, partFormatter) {
1146
1166
  const { slots, attrs } = context;
@@ -1180,7 +1200,9 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
1180
1200
  children = [parts];
1181
1201
  }
1182
1202
  const assignedAttrs = shared.assign({}, attrs);
1183
- const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : vue.Fragment;
1203
+ const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1204
+ ? props.tag
1205
+ : getFragmentableTag();
1184
1206
  return vue.h(tag, assignedAttrs, children);
1185
1207
  };
1186
1208
  }
@@ -1219,7 +1241,7 @@ const NUMBER_FORMAT_KEYS = [
1219
1241
  *
1220
1242
  * @VueI18nComponent
1221
1243
  */
1222
- const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1244
+ const NumberFormat = /* defineComponent */ {
1223
1245
  /* eslint-disable */
1224
1246
  name: 'i18n-n',
1225
1247
  props: shared.assign({
@@ -1232,6 +1254,7 @@ const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1232
1254
  }
1233
1255
  }, baseFormatProps),
1234
1256
  /* eslint-enable */
1257
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1235
1258
  setup(props, context) {
1236
1259
  const i18n = props.i18n ||
1237
1260
  useI18n({ useScope: 'parent', __useComponent: true });
@@ -1239,7 +1262,7 @@ const NumberFormat = /* #__PURE__*/ vue.defineComponent({
1239
1262
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1240
1263
  i18n[NumberPartsSymbol](...args));
1241
1264
  }
1242
- });
1265
+ };
1243
1266
 
1244
1267
  const DATETIME_FORMAT_KEYS = [
1245
1268
  'dateStyle',
@@ -1280,7 +1303,7 @@ const DATETIME_FORMAT_KEYS = [
1280
1303
  *
1281
1304
  * @VueI18nComponent
1282
1305
  */
1283
- const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1306
+ const DatetimeFormat = /*defineComponent */ {
1284
1307
  /* eslint-disable */
1285
1308
  name: 'i18n-d',
1286
1309
  props: shared.assign({
@@ -1293,6 +1316,7 @@ const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1293
1316
  }
1294
1317
  }, baseFormatProps),
1295
1318
  /* eslint-enable */
1319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1296
1320
  setup(props, context) {
1297
1321
  const i18n = props.i18n ||
1298
1322
  useI18n({ useScope: 'parent', __useComponent: true });
@@ -1300,7 +1324,7 @@ const DatetimeFormat = /* #__PURE__*/ vue.defineComponent({
1300
1324
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1301
1325
  i18n[DatetimePartsSymbol](...args));
1302
1326
  }
1303
- });
1327
+ };
1304
1328
 
1305
1329
  function getComposer$1(i18n, instance) {
1306
1330
  const i18nInternal = i18n;
@@ -1534,10 +1558,8 @@ function createI18n(options = {}, VueI18nLegacy) {
1534
1558
  // install plugin
1535
1559
  async install(app, ...options) {
1536
1560
  // setup global provider
1537
- {
1538
- app.__VUE_I18N_SYMBOL__ = symbol;
1539
- app.provide(app.__VUE_I18N_SYMBOL__, i18n);
1540
- }
1561
+ app.__VUE_I18N_SYMBOL__ = symbol;
1562
+ app.provide(app.__VUE_I18N_SYMBOL__, i18n);
1541
1563
  // global method and properties injection for Composition API
1542
1564
  if (!__legacyMode && __globalInjection) {
1543
1565
  injectGlobalFields(app, i18n.global);