vue-i18n 9.1.2 → 9.1.6

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.1.2
2
+ * vue-i18n v9.1.6
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.1.2';
22
+ const VERSION = '9.1.6';
23
23
 
24
24
  const warnMessages = {
25
25
  [6 /* FALLBACK_TO_ROOT */]: `Fall back to {type} '{key}' with root locale.`,
@@ -56,7 +56,7 @@ const NumberPartsSymbol = shared.makeSymbol('__numberParts');
56
56
  const EnableEmitter = shared.makeSymbol('__enableEmitter');
57
57
  const DisableEmitter = shared.makeSymbol('__disableEmitter');
58
58
  const SetPluralRulesSymbol = shared.makeSymbol('__setPluralRules');
59
- const DevToolsMetaSymbol = shared.makeSymbol('__intlifyMeta');
59
+ shared.makeSymbol('__intlifyMeta');
60
60
  let composerID = 0;
61
61
  function defineCoreMissingHandler(missing) {
62
62
  return ((ctx, locale, key, type) => {
@@ -115,13 +115,20 @@ function deepCopy(src, des) {
115
115
  }
116
116
  }
117
117
  }
118
+ // for Intlify DevTools
119
+ const getMetaInfo = /* #__PURE__*/ () => {
120
+ const instance = vue.getCurrentInstance();
121
+ return instance && instance.type[DEVTOOLS_META] // eslint-disable-line @typescript-eslint/no-explicit-any
122
+ ? { [DEVTOOLS_META]: instance.type[DEVTOOLS_META] } // eslint-disable-line @typescript-eslint/no-explicit-any
123
+ : null;
124
+ };
118
125
  /**
119
126
  * Create composer interface factory
120
127
  *
121
128
  * @internal
122
129
  */
123
130
  function createComposer(options = {}) {
124
- const { __root, __meta } = options;
131
+ const { __root } = options;
125
132
  const _isGlobal = __root === undefined;
126
133
  let _inheritLocale = shared.isBoolean(options.inheritLocale)
127
134
  ? options.inheritLocale
@@ -198,6 +205,7 @@ function createComposer(options = {}) {
198
205
  let _context;
199
206
  function getCoreContext() {
200
207
  return coreBase.createCoreContext({
208
+ version: VERSION,
201
209
  locale: _locale.value,
202
210
  fallbackLocale: _fallbackLocale.value,
203
211
  messages: _messages.value,
@@ -222,7 +230,7 @@ function createComposer(options = {}) {
222
230
  __v_emitter: shared.isPlainObject(_context)
223
231
  ? _context.__v_emitter
224
232
  : undefined,
225
- __meta: Object.assign({ framework: 'vue' }, __meta || {})
233
+ __meta: { framework: 'vue' }
226
234
  });
227
235
  }
228
236
  _context = getCoreContext();
@@ -287,7 +295,17 @@ function createComposer(options = {}) {
287
295
  }
288
296
  function wrapWithDeps(fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) {
289
297
  trackReactivityValues(); // track reactive dependency
290
- const ret = fn(_context);
298
+ // NOTE: experimental !!
299
+ let ret;
300
+ {
301
+ try {
302
+ coreBase.setAdditionalMeta(getMetaInfo());
303
+ ret = fn(_context);
304
+ }
305
+ finally {
306
+ coreBase.setAdditionalMeta(null);
307
+ }
308
+ }
291
309
  if (shared.isNumber(ret) && ret === coreBase.NOT_REOSLVED) {
292
310
  const [key, arg2] = argumentParser();
293
311
  if (__root &&
@@ -336,7 +354,7 @@ function createComposer(options = {}) {
336
354
  if (arg3 && !shared.isObject(arg3)) {
337
355
  throw createI18nError(15 /* INVALID_ARGUMENT */);
338
356
  }
339
- return t(...[arg1, arg2, Object.assign({ resolvedMessage: true }, arg3 || {})]);
357
+ return t(...[arg1, arg2, shared.assign({ resolvedMessage: true }, arg3 || {})]);
340
358
  }
341
359
  // d
342
360
  function d(...args) {
@@ -445,7 +463,7 @@ function createComposer(options = {}) {
445
463
  }
446
464
  // mergeDateTimeFormat
447
465
  function mergeDateTimeFormat(locale, format) {
448
- _datetimeFormats.value[locale] = Object.assign(_datetimeFormats.value[locale] || {}, format);
466
+ _datetimeFormats.value[locale] = shared.assign(_datetimeFormats.value[locale] || {}, format);
449
467
  _context.datetimeFormats = _datetimeFormats.value;
450
468
  coreBase.clearDateTimeFormat(_context, locale, format);
451
469
  }
@@ -461,7 +479,7 @@ function createComposer(options = {}) {
461
479
  }
462
480
  // mergeNumberFormat
463
481
  function mergeNumberFormat(locale, format) {
464
- _numberFormats.value[locale] = Object.assign(_numberFormats.value[locale] || {}, format);
482
+ _numberFormats.value[locale] = shared.assign(_numberFormats.value[locale] || {}, format);
465
483
  _context.numberFormats = _numberFormats.value;
466
484
  coreBase.clearNumberFormat(_context, locale, format);
467
485
  }
@@ -578,8 +596,7 @@ function createComposer(options = {}) {
578
596
  [TransrateVNodeSymbol]: transrateVNode,
579
597
  [NumberPartsSymbol]: numberParts,
580
598
  [DatetimePartsSymbol]: datetimeParts,
581
- [SetPluralRulesSymbol]: setPluralRules,
582
- [DevToolsMetaSymbol]: __meta
599
+ [SetPluralRulesSymbol]: setPluralRules
583
600
  };
584
601
  // for vue-devtools timeline event
585
602
  {
@@ -641,11 +658,11 @@ function convertComposerOptions(options) {
641
658
  const locales = Object.keys(sharedMessages);
642
659
  messages = locales.reduce((messages, locale) => {
643
660
  const message = messages[locale] || (messages[locale] = {});
644
- Object.assign(message, sharedMessages[locale]);
661
+ shared.assign(message, sharedMessages[locale]);
645
662
  return messages;
646
663
  }, (messages || {}));
647
664
  }
648
- const { __i18n, __root, __meta } = options;
665
+ const { __i18n, __root } = options;
649
666
  const datetimeFormats = options.datetimeFormats;
650
667
  const numberFormats = options.numberFormats;
651
668
  const flatJson = options.flatJson;
@@ -668,8 +685,7 @@ function convertComposerOptions(options) {
668
685
  escapeParameter,
669
686
  inheritLocale,
670
687
  __i18n,
671
- __root,
672
- __meta
688
+ __root
673
689
  };
674
690
  }
675
691
  /**
@@ -960,6 +976,9 @@ const baseFormatProps = {
960
976
  type: String,
961
977
  validator: (val) => val === 'parent' || val === 'global',
962
978
  default: 'parent'
979
+ },
980
+ i18n: {
981
+ type: Object
963
982
  }
964
983
  };
965
984
 
@@ -971,7 +990,7 @@ const baseFormatProps = {
971
990
  *
972
991
  * @VueI18nSee [TranslationProps](component#translationprops)
973
992
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
974
- * @VueI18nSee [Component Interpolation](../../guide/advanced/component)
993
+ * @VueI18nSee [Component Interpolation](../guide/advanced/component)
975
994
  *
976
995
  * @example
977
996
  * ```html
@@ -1029,7 +1048,8 @@ const Translation = {
1029
1048
  /* eslint-enable */
1030
1049
  setup(props, context) {
1031
1050
  const { slots, attrs } = context;
1032
- const i18n = useI18n({ useScope: props.scope });
1051
+ const i18n = props.i18n ||
1052
+ useI18n({ useScope: props.scope });
1033
1053
  const keys = Object.keys(slots).filter(key => key !== '_');
1034
1054
  return () => {
1035
1055
  const options = {};
@@ -1089,7 +1109,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
1089
1109
  // Filter out number format options only
1090
1110
  overrides = Object.keys(props.format).reduce((options, prop) => {
1091
1111
  return slotKeys.includes(prop)
1092
- ? Object.assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
1112
+ ? shared.assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
1093
1113
  : options;
1094
1114
  }, {});
1095
1115
  }
@@ -1141,7 +1161,7 @@ const NUMBER_FORMAT_KEYS = [
1141
1161
  *
1142
1162
  * @VueI18nSee [FormattableProps](component#formattableprops)
1143
1163
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1144
- * @VueI18nSee [Custom Formatting](../../guide/essentials/number#custom-formatting)
1164
+ * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
1145
1165
  *
1146
1166
  * @VueI18nDanger
1147
1167
  * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
@@ -1164,7 +1184,8 @@ const NumberFormat = {
1164
1184
  }, baseFormatProps),
1165
1185
  /* eslint-enable */
1166
1186
  setup(props, context) {
1167
- const i18n = useI18n({ useScope: 'parent' });
1187
+ const i18n = props.i18n ||
1188
+ useI18n({ useScope: 'parent' });
1168
1189
  return renderFormatter(props, context, NUMBER_FORMAT_KEYS, (...args) =>
1169
1190
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1170
1191
  i18n[NumberPartsSymbol](...args));
@@ -1201,7 +1222,7 @@ const DATETIME_FORMAT_KEYS = [
1201
1222
  *
1202
1223
  * @VueI18nSee [FormattableProps](component#formattableprops)
1203
1224
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1204
- * @VueI18nSee [Custom Formatting](../../guide/essentials/datetime#custom-formatting)
1225
+ * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
1205
1226
  *
1206
1227
  * @VueI18nDanger
1207
1228
  * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
@@ -1224,7 +1245,8 @@ const DatetimeFormat = {
1224
1245
  }, baseFormatProps),
1225
1246
  /* eslint-enable */
1226
1247
  setup(props, context) {
1227
- const i18n = useI18n({ useScope: 'parent' });
1248
+ const i18n = props.i18n ||
1249
+ useI18n({ useScope: 'parent' });
1228
1250
  return renderFormatter(props, context, DATETIME_FORMAT_KEYS, (...args) =>
1229
1251
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1230
1252
  i18n[DatetimePartsSymbol](...args));
@@ -1329,9 +1351,6 @@ function defineMixin(vuei18n, composer, i18n) {
1329
1351
  if (options.__i18n) {
1330
1352
  optionsI18n.__i18n = options.__i18n;
1331
1353
  }
1332
- optionsI18n.__meta = options[DEVTOOLS_META]
1333
- ? { [DEVTOOLS_META]: options[DEVTOOLS_META] }
1334
- : {};
1335
1354
  optionsI18n.__root = composer;
1336
1355
  if (this === this.$root) {
1337
1356
  this.$i18n = mergeToRoot(vuei18n, optionsI18n);
@@ -1347,9 +1366,6 @@ function defineMixin(vuei18n, composer, i18n) {
1347
1366
  else {
1348
1367
  this.$i18n = createVueI18n({
1349
1368
  __i18n: options.__i18n,
1350
- __meta: options[DEVTOOLS_META]
1351
- ? { [DEVTOOLS_META]: options[DEVTOOLS_META] }
1352
- : {},
1353
1369
  __root: composer
1354
1370
  });
1355
1371
  }
@@ -1405,14 +1421,6 @@ function mergeToRoot(root, options) {
1405
1421
  options.escapeParameterHtml || root.escapeParameterHtml;
1406
1422
  root.sync = options.sync || root.sync;
1407
1423
  root.__composer[SetPluralRulesSymbol](options.pluralizationRules || root.pluralizationRules);
1408
- /* eslint-disable @typescript-eslint/no-explicit-any */
1409
- if (options[DEVTOOLS_META] &&
1410
- !root.__composer[DevToolsMetaSymbol]) {
1411
- root.__composer[DevToolsMetaSymbol] = {
1412
- [DEVTOOLS_META]: options[DEVTOOLS_META]
1413
- };
1414
- }
1415
- /* eslint-enable @typescript-eslint/no-explicit-any */
1416
1424
  const messages = getLocaleMessages(root.locale, {
1417
1425
  messages: options.messages,
1418
1426
  __i18n: options.__i18n
@@ -1439,8 +1447,8 @@ function mergeToRoot(root, options) {
1439
1447
  *
1440
1448
  * If you use composition API mode, you need to specify {@link ComposerOptions}.
1441
1449
  *
1442
- * @VueI18nSee [Getting Started](../../guide/)
1443
- * @VueI18nSee [Composition API](../../guide/advanced/composition)
1450
+ * @VueI18nSee [Getting Started](../guide/)
1451
+ * @VueI18nSee [Composition API](../guide/advanced/composition)
1444
1452
  *
1445
1453
  * @example
1446
1454
  * case: for Legacy API
@@ -1689,16 +1697,10 @@ function useI18n(options = {}) {
1689
1697
  let composer = i18nInternal.__getInstance(instance);
1690
1698
  if (composer == null) {
1691
1699
  const type = instance.type;
1692
- const composerOptions = {
1693
- ...options
1694
- };
1700
+ const composerOptions = shared.assign({}, options);
1695
1701
  if (type.__i18n) {
1696
1702
  composerOptions.__i18n = type.__i18n;
1697
1703
  }
1698
- if (type[DEVTOOLS_META]) {
1699
- composerOptions.__meta = composerOptions.__meta || {};
1700
- composerOptions.__meta[DEVTOOLS_META] = type[DEVTOOLS_META];
1701
- }
1702
1704
  if (global) {
1703
1705
  composerOptions.__root = global;
1704
1706
  }
@@ -1774,7 +1776,7 @@ function injectGlobalFields(app, composer) {
1774
1776
  app.config.globalProperties.$i18n = i18n;
1775
1777
  globalExportMethods.forEach(method => {
1776
1778
  const desc = Object.getOwnPropertyDescriptor(composer, method);
1777
- if (!desc) {
1779
+ if (!desc || !desc.value) {
1778
1780
  throw createI18nError(22 /* UNEXPECTED_ERROR */);
1779
1781
  }
1780
1782
  Object.defineProperty(app.config.globalProperties, `$${method}`, desc);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v9.1.2
2
+ * vue-i18n v9.1.6
3
3
  * (c) 2021 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -19,20 +19,19 @@ var shared = require('@intlify/shared');
19
19
  *
20
20
  * @VueI18nGeneral
21
21
  */
22
- const VERSION = '9.1.2';
22
+ const VERSION = '9.1.6';
23
23
 
24
24
  function createI18nError(code, ...args) {
25
25
  return coreBase.createCompileError(code, null, undefined);
26
26
  }
27
27
 
28
- const DEVTOOLS_META = '__INTLIFY_META__';
29
28
  const TransrateVNodeSymbol = shared.makeSymbol('__transrateVNode');
30
29
  const DatetimePartsSymbol = shared.makeSymbol('__datetimeParts');
31
30
  const NumberPartsSymbol = shared.makeSymbol('__numberParts');
32
31
  shared.makeSymbol('__enableEmitter');
33
32
  shared.makeSymbol('__disableEmitter');
34
33
  const SetPluralRulesSymbol = shared.makeSymbol('__setPluralRules');
35
- const DevToolsMetaSymbol = shared.makeSymbol('__intlifyMeta');
34
+ shared.makeSymbol('__intlifyMeta');
36
35
  let composerID = 0;
37
36
  function defineCoreMissingHandler(missing) {
38
37
  return ((ctx, locale, key, type) => {
@@ -97,7 +96,7 @@ function deepCopy(src, des) {
97
96
  * @internal
98
97
  */
99
98
  function createComposer(options = {}) {
100
- const { __root, __meta } = options;
99
+ const { __root } = options;
101
100
  const _isGlobal = __root === undefined;
102
101
  let _inheritLocale = shared.isBoolean(options.inheritLocale)
103
102
  ? options.inheritLocale
@@ -174,6 +173,7 @@ function createComposer(options = {}) {
174
173
  let _context;
175
174
  function getCoreContext() {
176
175
  return coreBase.createCoreContext({
176
+ version: VERSION,
177
177
  locale: _locale.value,
178
178
  fallbackLocale: _fallbackLocale.value,
179
179
  messages: _messages.value,
@@ -198,7 +198,7 @@ function createComposer(options = {}) {
198
198
  __v_emitter: shared.isPlainObject(_context)
199
199
  ? _context.__v_emitter
200
200
  : undefined,
201
- __meta: Object.assign({ framework: 'vue' }, __meta || {})
201
+ __meta: { framework: 'vue' }
202
202
  });
203
203
  }
204
204
  _context = getCoreContext();
@@ -259,7 +259,11 @@ function createComposer(options = {}) {
259
259
  }
260
260
  function wrapWithDeps(fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) {
261
261
  trackReactivityValues(); // track reactive dependency
262
- const ret = fn(_context);
262
+ // NOTE: experimental !!
263
+ let ret;
264
+ {
265
+ ret = fn(_context);
266
+ }
263
267
  if (shared.isNumber(ret) && ret === coreBase.NOT_REOSLVED) {
264
268
  const [key, arg2] = argumentParser();
265
269
  return __root && _fallbackRoot
@@ -284,7 +288,7 @@ function createComposer(options = {}) {
284
288
  if (arg3 && !shared.isObject(arg3)) {
285
289
  throw createI18nError(15 /* INVALID_ARGUMENT */);
286
290
  }
287
- return t(...[arg1, arg2, Object.assign({ resolvedMessage: true }, arg3 || {})]);
291
+ return t(...[arg1, arg2, shared.assign({ resolvedMessage: true }, arg3 || {})]);
288
292
  }
289
293
  // d
290
294
  function d(...args) {
@@ -393,7 +397,7 @@ function createComposer(options = {}) {
393
397
  }
394
398
  // mergeDateTimeFormat
395
399
  function mergeDateTimeFormat(locale, format) {
396
- _datetimeFormats.value[locale] = Object.assign(_datetimeFormats.value[locale] || {}, format);
400
+ _datetimeFormats.value[locale] = shared.assign(_datetimeFormats.value[locale] || {}, format);
397
401
  _context.datetimeFormats = _datetimeFormats.value;
398
402
  coreBase.clearDateTimeFormat(_context, locale, format);
399
403
  }
@@ -409,7 +413,7 @@ function createComposer(options = {}) {
409
413
  }
410
414
  // mergeNumberFormat
411
415
  function mergeNumberFormat(locale, format) {
412
- _numberFormats.value[locale] = Object.assign(_numberFormats.value[locale] || {}, format);
416
+ _numberFormats.value[locale] = shared.assign(_numberFormats.value[locale] || {}, format);
413
417
  _context.numberFormats = _numberFormats.value;
414
418
  coreBase.clearNumberFormat(_context, locale, format);
415
419
  }
@@ -526,8 +530,7 @@ function createComposer(options = {}) {
526
530
  [TransrateVNodeSymbol]: transrateVNode,
527
531
  [NumberPartsSymbol]: numberParts,
528
532
  [DatetimePartsSymbol]: datetimeParts,
529
- [SetPluralRulesSymbol]: setPluralRules,
530
- [DevToolsMetaSymbol]: __meta
533
+ [SetPluralRulesSymbol]: setPluralRules
531
534
  };
532
535
  return composer;
533
536
  }
@@ -574,11 +577,11 @@ function convertComposerOptions(options) {
574
577
  const locales = Object.keys(sharedMessages);
575
578
  messages = locales.reduce((messages, locale) => {
576
579
  const message = messages[locale] || (messages[locale] = {});
577
- Object.assign(message, sharedMessages[locale]);
580
+ shared.assign(message, sharedMessages[locale]);
578
581
  return messages;
579
582
  }, (messages || {}));
580
583
  }
581
- const { __i18n, __root, __meta } = options;
584
+ const { __i18n, __root } = options;
582
585
  const datetimeFormats = options.datetimeFormats;
583
586
  const numberFormats = options.numberFormats;
584
587
  const flatJson = options.flatJson;
@@ -601,8 +604,7 @@ function convertComposerOptions(options) {
601
604
  escapeParameter,
602
605
  inheritLocale,
603
606
  __i18n,
604
- __root,
605
- __meta
607
+ __root
606
608
  };
607
609
  }
608
610
  /**
@@ -875,6 +877,9 @@ const baseFormatProps = {
875
877
  type: String,
876
878
  validator: (val) => val === 'parent' || val === 'global',
877
879
  default: 'parent'
880
+ },
881
+ i18n: {
882
+ type: Object
878
883
  }
879
884
  };
880
885
 
@@ -886,7 +891,7 @@ const baseFormatProps = {
886
891
  *
887
892
  * @VueI18nSee [TranslationProps](component#translationprops)
888
893
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
889
- * @VueI18nSee [Component Interpolation](../../guide/advanced/component)
894
+ * @VueI18nSee [Component Interpolation](../guide/advanced/component)
890
895
  *
891
896
  * @example
892
897
  * ```html
@@ -944,7 +949,8 @@ const Translation = {
944
949
  /* eslint-enable */
945
950
  setup(props, context) {
946
951
  const { slots, attrs } = context;
947
- const i18n = useI18n({ useScope: props.scope });
952
+ const i18n = props.i18n ||
953
+ useI18n({ useScope: props.scope });
948
954
  const keys = Object.keys(slots).filter(key => key !== '_');
949
955
  return () => {
950
956
  const options = {};
@@ -1004,7 +1010,7 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
1004
1010
  // Filter out number format options only
1005
1011
  overrides = Object.keys(props.format).reduce((options, prop) => {
1006
1012
  return slotKeys.includes(prop)
1007
- ? Object.assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
1013
+ ? shared.assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
1008
1014
  : options;
1009
1015
  }, {});
1010
1016
  }
@@ -1056,7 +1062,7 @@ const NUMBER_FORMAT_KEYS = [
1056
1062
  *
1057
1063
  * @VueI18nSee [FormattableProps](component#formattableprops)
1058
1064
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1059
- * @VueI18nSee [Custom Formatting](../../guide/essentials/number#custom-formatting)
1065
+ * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
1060
1066
  *
1061
1067
  * @VueI18nDanger
1062
1068
  * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
@@ -1079,7 +1085,8 @@ const NumberFormat = {
1079
1085
  }, baseFormatProps),
1080
1086
  /* eslint-enable */
1081
1087
  setup(props, context) {
1082
- const i18n = useI18n({ useScope: 'parent' });
1088
+ const i18n = props.i18n ||
1089
+ useI18n({ useScope: 'parent' });
1083
1090
  return renderFormatter(props, context, NUMBER_FORMAT_KEYS, (...args) =>
1084
1091
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1085
1092
  i18n[NumberPartsSymbol](...args));
@@ -1116,7 +1123,7 @@ const DATETIME_FORMAT_KEYS = [
1116
1123
  *
1117
1124
  * @VueI18nSee [FormattableProps](component#formattableprops)
1118
1125
  * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1119
- * @VueI18nSee [Custom Formatting](../../guide/essentials/datetime#custom-formatting)
1126
+ * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
1120
1127
  *
1121
1128
  * @VueI18nDanger
1122
1129
  * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
@@ -1139,7 +1146,8 @@ const DatetimeFormat = {
1139
1146
  }, baseFormatProps),
1140
1147
  /* eslint-enable */
1141
1148
  setup(props, context) {
1142
- const i18n = useI18n({ useScope: 'parent' });
1149
+ const i18n = props.i18n ||
1150
+ useI18n({ useScope: 'parent' });
1143
1151
  return renderFormatter(props, context, DATETIME_FORMAT_KEYS, (...args) =>
1144
1152
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1145
1153
  i18n[DatetimePartsSymbol](...args));
@@ -1236,9 +1244,6 @@ function defineMixin(vuei18n, composer, i18n) {
1236
1244
  if (options.__i18n) {
1237
1245
  optionsI18n.__i18n = options.__i18n;
1238
1246
  }
1239
- optionsI18n.__meta = options[DEVTOOLS_META]
1240
- ? { [DEVTOOLS_META]: options[DEVTOOLS_META] }
1241
- : {};
1242
1247
  optionsI18n.__root = composer;
1243
1248
  if (this === this.$root) {
1244
1249
  this.$i18n = mergeToRoot(vuei18n, optionsI18n);
@@ -1254,9 +1259,6 @@ function defineMixin(vuei18n, composer, i18n) {
1254
1259
  else {
1255
1260
  this.$i18n = createVueI18n({
1256
1261
  __i18n: options.__i18n,
1257
- __meta: options[DEVTOOLS_META]
1258
- ? { [DEVTOOLS_META]: options[DEVTOOLS_META] }
1259
- : {},
1260
1262
  __root: composer
1261
1263
  });
1262
1264
  }
@@ -1312,14 +1314,6 @@ function mergeToRoot(root, options) {
1312
1314
  options.escapeParameterHtml || root.escapeParameterHtml;
1313
1315
  root.sync = options.sync || root.sync;
1314
1316
  root.__composer[SetPluralRulesSymbol](options.pluralizationRules || root.pluralizationRules);
1315
- /* eslint-disable @typescript-eslint/no-explicit-any */
1316
- if (options[DEVTOOLS_META] &&
1317
- !root.__composer[DevToolsMetaSymbol]) {
1318
- root.__composer[DevToolsMetaSymbol] = {
1319
- [DEVTOOLS_META]: options[DEVTOOLS_META]
1320
- };
1321
- }
1322
- /* eslint-enable @typescript-eslint/no-explicit-any */
1323
1317
  const messages = getLocaleMessages(root.locale, {
1324
1318
  messages: options.messages,
1325
1319
  __i18n: options.__i18n
@@ -1346,8 +1340,8 @@ function mergeToRoot(root, options) {
1346
1340
  *
1347
1341
  * If you use composition API mode, you need to specify {@link ComposerOptions}.
1348
1342
  *
1349
- * @VueI18nSee [Getting Started](../../guide/)
1350
- * @VueI18nSee [Composition API](../../guide/advanced/composition)
1343
+ * @VueI18nSee [Getting Started](../guide/)
1344
+ * @VueI18nSee [Composition API](../guide/advanced/composition)
1351
1345
  *
1352
1346
  * @example
1353
1347
  * case: for Legacy API
@@ -1593,16 +1587,10 @@ function useI18n(options = {}) {
1593
1587
  let composer = i18nInternal.__getInstance(instance);
1594
1588
  if (composer == null) {
1595
1589
  const type = instance.type;
1596
- const composerOptions = {
1597
- ...options
1598
- };
1590
+ const composerOptions = shared.assign({}, options);
1599
1591
  if (type.__i18n) {
1600
1592
  composerOptions.__i18n = type.__i18n;
1601
1593
  }
1602
- if (type[DEVTOOLS_META]) {
1603
- composerOptions.__meta = composerOptions.__meta || {};
1604
- composerOptions.__meta[DEVTOOLS_META] = type[DEVTOOLS_META];
1605
- }
1606
1594
  if (global) {
1607
1595
  composerOptions.__root = global;
1608
1596
  }
@@ -1678,7 +1666,7 @@ function injectGlobalFields(app, composer) {
1678
1666
  app.config.globalProperties.$i18n = i18n;
1679
1667
  globalExportMethods.forEach(method => {
1680
1668
  const desc = Object.getOwnPropertyDescriptor(composer, method);
1681
- if (!desc) {
1669
+ if (!desc || !desc.value) {
1682
1670
  throw createI18nError(22 /* UNEXPECTED_ERROR */);
1683
1671
  }
1684
1672
  Object.defineProperty(app.config.globalProperties, `$${method}`, desc);