vue-i18n 11.1.12 → 11.2.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v11.1.12
2
+ * vue-i18n v11.2.2
3
3
  * (c) 2025 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -7,7 +7,20 @@
7
7
 
8
8
  var coreBase = require('@intlify/core-base');
9
9
  var shared = require('@intlify/shared');
10
- var vue = require('vue');
10
+ var Vue = require('vue');
11
+
12
+ function _interopNamespaceDefault(e) {
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ for (var k in e) {
16
+ n[k] = e[k];
17
+ }
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var Vue__namespace = /*#__PURE__*/_interopNamespaceDefault(Vue);
11
24
 
12
25
  /**
13
26
  * Vue I18n Version
@@ -17,7 +30,7 @@ var vue = require('vue');
17
30
  *
18
31
  * @VueI18nGeneral
19
32
  */
20
- const VERSION = '11.1.12';
33
+ const VERSION = '11.2.2';
21
34
 
22
35
  const I18nErrorCodes = {
23
36
  // composer module errors
@@ -204,8 +217,19 @@ function adjustI18nResources(gl, options, componentOptions) {
204
217
  }
205
218
  }
206
219
  function createTextNode(key) {
207
- return vue.createVNode(vue.Text, null, key, 0);
220
+ return Vue.createVNode(Vue.Text, null, key, 0);
221
+ }
222
+ function getCurrentInstance() {
223
+ if ('currentInstance' in Vue__namespace) {
224
+ // NOTE(kazupon): avoid bundler static analysis
225
+ const name = 'current' + 'Instance';
226
+ return Vue__namespace[name];
227
+ }
228
+ else {
229
+ return Vue__namespace.getCurrentInstance();
230
+ }
208
231
  }
232
+ /* eslint-enable @typescript-eslint/no-explicit-any */
209
233
 
210
234
  /* eslint-disable @typescript-eslint/no-explicit-any */
211
235
  // extend VNode interface
@@ -215,13 +239,13 @@ const NOOP_RETURN_FALSE = () => false;
215
239
  let composerID = 0;
216
240
  function defineCoreMissingHandler(missing) {
217
241
  return ((ctx, locale, key, type) => {
218
- return missing(locale, key, vue.getCurrentInstance() || undefined, type);
242
+ return missing(locale, key, getCurrentInstance() || undefined, type);
219
243
  });
220
244
  }
221
245
  // for Intlify DevTools
222
246
  /* #__NO_SIDE_EFFECTS__ */
223
247
  const getMetaInfo = () => {
224
- const instance = vue.getCurrentInstance();
248
+ const instance = getCurrentInstance();
225
249
  let meta = null;
226
250
  return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META])
227
251
  ? { [DEVTOOLS_META]: meta }
@@ -236,7 +260,7 @@ function createComposer(options = {}) {
236
260
  const { __root, __injectWithOption } = options;
237
261
  const _isGlobal = __root === undefined;
238
262
  const flatJson = options.flatJson;
239
- const _ref = shared.inBrowser ? vue.ref : vue.shallowRef;
263
+ const _ref = shared.inBrowser ? Vue.ref : Vue.shallowRef;
240
264
  let _inheritLocale = shared.isBoolean(options.inheritLocale)
241
265
  ? options.inheritLocale
242
266
  : true;
@@ -366,7 +390,7 @@ function createComposer(options = {}) {
366
390
  ;
367
391
  }
368
392
  // locale
369
- const locale = vue.computed({
393
+ const locale = Vue.computed({
370
394
  get: () => _locale.value,
371
395
  set: val => {
372
396
  _context.locale = val;
@@ -374,7 +398,7 @@ function createComposer(options = {}) {
374
398
  }
375
399
  });
376
400
  // fallbackLocale
377
- const fallbackLocale = vue.computed({
401
+ const fallbackLocale = Vue.computed({
378
402
  get: () => _fallbackLocale.value,
379
403
  set: val => {
380
404
  _context.fallbackLocale = val;
@@ -383,11 +407,11 @@ function createComposer(options = {}) {
383
407
  }
384
408
  });
385
409
  // messages
386
- const messages = vue.computed(() => _messages.value);
410
+ const messages = Vue.computed(() => _messages.value);
387
411
  // datetimeFormats
388
- const datetimeFormats = /* #__PURE__*/ vue.computed(() => _datetimeFormats.value);
412
+ const datetimeFormats = /* #__PURE__*/ Vue.computed(() => _datetimeFormats.value);
389
413
  // numberFormats
390
- const numberFormats = /* #__PURE__*/ vue.computed(() => _numberFormats.value);
414
+ const numberFormats = /* #__PURE__*/ Vue.computed(() => _numberFormats.value);
391
415
  // getPostTranslationHandler
392
416
  function getPostTranslationHandler() {
393
417
  return shared.isFunction(_postTranslation) ? _postTranslation : null;
@@ -612,14 +636,14 @@ function createComposer(options = {}) {
612
636
  composerID++;
613
637
  // watch root locale & fallbackLocale
614
638
  if (__root && shared.inBrowser) {
615
- vue.watch(__root.locale, (val) => {
639
+ Vue.watch(__root.locale, (val) => {
616
640
  if (_inheritLocale) {
617
641
  _locale.value = val;
618
642
  _context.locale = val;
619
643
  coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
620
644
  }
621
645
  });
622
- vue.watch(__root.fallbackLocale, (val) => {
646
+ Vue.watch(__root.fallbackLocale, (val) => {
623
647
  if (_inheritLocale) {
624
648
  _fallbackLocale.value = val;
625
649
  _context.fallbackLocale = val;
@@ -992,7 +1016,7 @@ function createVueI18n(options = {}) {
992
1016
  function defineMixin(vuei18n, composer, i18n) {
993
1017
  return {
994
1018
  beforeCreate() {
995
- const instance = vue.getCurrentInstance();
1019
+ const instance = getCurrentInstance();
996
1020
  /* istanbul ignore if */
997
1021
  if (!instance) {
998
1022
  throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
@@ -1059,7 +1083,7 @@ function defineMixin(vuei18n, composer, i18n) {
1059
1083
  mounted() {
1060
1084
  },
1061
1085
  unmounted() {
1062
- const instance = vue.getCurrentInstance();
1086
+ const instance = getCurrentInstance();
1063
1087
  /* istanbul ignore if */
1064
1088
  if (!instance) {
1065
1089
  throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
@@ -1139,7 +1163,7 @@ keys) {
1139
1163
  return [
1140
1164
  ...slot,
1141
1165
  // prettier-ignore
1142
- ...(current.type === vue.Fragment ? current.children : [current])
1166
+ ...(current.type === Vue.Fragment ? current.children : [current])
1143
1167
  ];
1144
1168
  }, []);
1145
1169
  }
@@ -1156,10 +1180,10 @@ keys) {
1156
1180
  }
1157
1181
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1158
1182
  function getFragmentableTag() {
1159
- return vue.Fragment;
1183
+ return Vue.Fragment;
1160
1184
  }
1161
1185
 
1162
- const TranslationImpl = /*#__PURE__*/ vue.defineComponent({
1186
+ const TranslationImpl = /*#__PURE__*/ Vue.defineComponent({
1163
1187
  /* eslint-disable */
1164
1188
  name: 'i18n-t',
1165
1189
  props: shared.assign({
@@ -1198,7 +1222,7 @@ const TranslationImpl = /*#__PURE__*/ vue.defineComponent({
1198
1222
  const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1199
1223
  ? props.tag
1200
1224
  : getFragmentableTag();
1201
- return vue.h(tag, assignedAttrs, children);
1225
+ return Vue.h(tag, assignedAttrs, children);
1202
1226
  };
1203
1227
  }
1204
1228
  });
@@ -1306,11 +1330,11 @@ function renderFormatter(props, context, slotKeys, partFormatter) {
1306
1330
  const tag = shared.isString(props.tag) || shared.isObject(props.tag)
1307
1331
  ? props.tag
1308
1332
  : getFragmentableTag();
1309
- return vue.h(tag, assignedAttrs, children);
1333
+ return Vue.h(tag, assignedAttrs, children);
1310
1334
  };
1311
1335
  }
1312
1336
 
1313
- const NumberFormatImpl = /*#__PURE__*/ vue.defineComponent({
1337
+ const NumberFormatImpl = /*#__PURE__*/ Vue.defineComponent({
1314
1338
  /* eslint-disable */
1315
1339
  name: 'i18n-n',
1316
1340
  props: shared.assign({
@@ -1392,7 +1416,7 @@ function vTDirective(i18n) {
1392
1416
  const [textContent, composer] = _process(binding);
1393
1417
  if (shared.inBrowser && i18n.global === composer) {
1394
1418
  // global scope only
1395
- el.__i18nWatcher = vue.watch(composer.locale, () => {
1419
+ el.__i18nWatcher = Vue.watch(composer.locale, () => {
1396
1420
  binding.instance && binding.instance.$forceUpdate();
1397
1421
  });
1398
1422
  }
@@ -1571,7 +1595,7 @@ function createI18n(options = {}) {
1571
1595
  return i18n;
1572
1596
  }
1573
1597
  function useI18n(options = {}) {
1574
- const instance = vue.getCurrentInstance();
1598
+ const instance = getCurrentInstance();
1575
1599
  if (instance == null) {
1576
1600
  throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP);
1577
1601
  }
@@ -1617,7 +1641,7 @@ function useI18n(options = {}) {
1617
1641
  return composer;
1618
1642
  }
1619
1643
  function createGlobal(options, legacyMode) {
1620
- const scope = vue.effectScope();
1644
+ const scope = Vue.effectScope();
1621
1645
  const obj = legacyMode
1622
1646
  ? scope.run(() => createVueI18n(options))
1623
1647
  : scope.run(() => createComposer(options));
@@ -1627,7 +1651,7 @@ function createGlobal(options, legacyMode) {
1627
1651
  return [scope, obj];
1628
1652
  }
1629
1653
  function getI18nInstance(instance) {
1630
- const i18n = vue.inject(!instance.isCE
1654
+ const i18n = Vue.inject(!instance.isCE
1631
1655
  ? instance.appContext.app.__VUE_I18N_SYMBOL__
1632
1656
  : I18nInjectionKey);
1633
1657
  /* istanbul ignore if */
@@ -1699,9 +1723,9 @@ function getParentComponentInstance(target, useComponent = false) {
1699
1723
  : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any
1700
1724
  }
1701
1725
  function setupLifeCycle(i18n, target, composer) {
1702
- vue.onMounted(() => {
1726
+ Vue.onMounted(() => {
1703
1727
  }, target);
1704
- vue.onUnmounted(() => {
1728
+ Vue.onUnmounted(() => {
1705
1729
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1706
1730
  const _composer = composer;
1707
1731
  i18n.__deleteInstance(target);
@@ -1727,7 +1751,7 @@ function injectGlobalFields(app, composer) {
1727
1751
  if (!desc) {
1728
1752
  throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
1729
1753
  }
1730
- const wrap = vue.isRef(desc.value) // check computed props
1754
+ const wrap = Vue.isRef(desc.value) // check computed props
1731
1755
  ? {
1732
1756
  get() {
1733
1757
  return desc.value.value;
@@ -1763,7 +1787,7 @@ function injectGlobalFields(app, composer) {
1763
1787
  return dispose;
1764
1788
  }
1765
1789
 
1766
- const DatetimeFormatImpl = /* #__PURE__*/ vue.defineComponent({
1790
+ const DatetimeFormatImpl = /* #__PURE__*/ Vue.defineComponent({
1767
1791
  /* eslint-disable */
1768
1792
  name: 'i18n-d',
1769
1793
  props: shared.assign({
@@ -7,6 +7,7 @@ import { FallbackLocale } from '@intlify/core-base';
7
7
  import type { FallbackLocales } from '@intlify/core-base';
8
8
  import type { GeneratedLocale } from '@intlify/core-base';
9
9
  import { GeneratedTypeConfig } from '@intlify/core-base';
10
+ import type { GenericComponentInstance } from 'vue';
10
11
  import { InjectionKey } from 'vue';
11
12
  import { DateTimeFormat as IntlDateTimeFormat } from '@intlify/core-base';
12
13
  import { DateTimeFormats as IntlDateTimeFormats } from '@intlify/core-base';
@@ -1865,7 +1866,7 @@ export { MessageFunctions }
1865
1866
  export { MessageResolver }
1866
1867
 
1867
1868
  /** @VueI18nComposition */
1868
- export declare type MissingHandler = (locale: Locale, key: Path, instance?: ComponentInternalInstance, type?: string) => string | void;
1869
+ export declare type MissingHandler = (locale: Locale, key: Path, instance?: ComponentInternalInstance | GenericComponentInstance, type?: string) => string | void;
1869
1870
  export { NamedValue }
1870
1871
 
1871
1872
  /**
@@ -1,9 +1,10 @@
1
1
  /*!
2
- * vue-i18n v11.1.12
2
+ * vue-i18n v11.2.2
3
3
  * (c) 2025 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
6
- import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, isRef } from 'vue';
6
+ import * as Vue from 'vue';
7
+ import { createVNode, Text, computed, watch, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, isRef } from 'vue';
7
8
 
8
9
  function warn(msg, err) {
9
10
  if (typeof console !== 'undefined') {
@@ -2515,7 +2516,7 @@ function getWarnMessage$1(code, ...args) {
2515
2516
  * Intlify core-base version
2516
2517
  * @internal
2517
2518
  */
2518
- const VERSION$1 = '11.1.12';
2519
+ const VERSION$1 = '11.2.2';
2519
2520
  const NOT_REOSLVED = -1;
2520
2521
  const DEFAULT_LOCALE = 'en-US';
2521
2522
  const MISSING_RESOLVE_VALUE = '';
@@ -3644,7 +3645,7 @@ function getMessageContextOptions(context, locale, message, options) {
3644
3645
  *
3645
3646
  * @VueI18nGeneral
3646
3647
  */
3647
- const VERSION = '11.1.12';
3648
+ const VERSION = '11.2.2';
3648
3649
  /**
3649
3650
  * This is only called development env
3650
3651
  * istanbul-ignore-next
@@ -3895,6 +3896,17 @@ function adjustI18nResources(gl, options, componentOptions) {
3895
3896
  function createTextNode(key) {
3896
3897
  return createVNode(Text, null, key, 0);
3897
3898
  }
3899
+ function getCurrentInstance() {
3900
+ if ('currentInstance' in Vue) {
3901
+ // NOTE(kazupon): avoid bundler static analysis
3902
+ const name = 'current' + 'Instance';
3903
+ return Vue[name];
3904
+ }
3905
+ else {
3906
+ return Vue.getCurrentInstance();
3907
+ }
3908
+ }
3909
+ /* eslint-enable @typescript-eslint/no-explicit-any */
3898
3910
 
3899
3911
  /* eslint-disable @typescript-eslint/no-explicit-any */
3900
3912
  // extend VNode interface
@@ -4663,18 +4675,16 @@ async function enableDevTools(app, i18n) {
4663
4675
  updateComponentTreeTags(componentInstance, treeNode, i18n);
4664
4676
  });
4665
4677
  api.on.inspectComponent(({ componentInstance, instanceData }) => {
4666
- if (componentInstance.vnode.el &&
4667
- componentInstance.vnode.el.__VUE_I18N__ &&
4668
- instanceData) {
4678
+ if (componentInstance.__VUE_I18N__ && instanceData) {
4669
4679
  if (i18n.mode === 'legacy') {
4670
4680
  // ignore global scope on legacy mode
4671
- if (componentInstance.vnode.el.__VUE_I18N__ !==
4681
+ if (componentInstance.__VUE_I18N__ !==
4672
4682
  i18n.global.__composer) {
4673
- inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__);
4683
+ inspectComposer(instanceData, componentInstance.__VUE_I18N__);
4674
4684
  }
4675
4685
  }
4676
4686
  else {
4677
- inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__);
4687
+ inspectComposer(instanceData, componentInstance.__VUE_I18N__);
4678
4688
  }
4679
4689
  }
4680
4690
  });
@@ -4743,9 +4753,9 @@ treeNode, i18n) {
4743
4753
  const global = i18n.mode === 'composition'
4744
4754
  ? i18n.global
4745
4755
  : i18n.global.__composer;
4746
- if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) {
4756
+ if (instance && instance.__VUE_I18N__) {
4747
4757
  // add custom tags local scope only
4748
- if (instance.vnode.el.__VUE_I18N__ !== global) {
4758
+ if (instance.__VUE_I18N__ !== global) {
4749
4759
  const tag = {
4750
4760
  label: `i18n (${getI18nScopeLable(instance)} Scope)`,
4751
4761
  textColor: 0x000000,
@@ -5354,10 +5364,13 @@ function defineMixin(vuei18n, composer, i18n) {
5354
5364
  },
5355
5365
  mounted() {
5356
5366
  /* istanbul ignore if */
5357
- if (this.$el &&
5358
- this.$i18n) {
5367
+ if (this.$i18n) {
5368
+ const instance = getCurrentInstance();
5369
+ if (!instance) {
5370
+ return;
5371
+ }
5359
5372
  const _vueI18n = this.$i18n;
5360
- this.$el.__VUE_I18N__ = _vueI18n.__composer;
5373
+ instance.__VUE_I18N__ = _vueI18n.__composer;
5361
5374
  const emitter = (this.__v_emitter =
5362
5375
  createEmitter());
5363
5376
  _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter);
@@ -5372,15 +5385,14 @@ function defineMixin(vuei18n, composer, i18n) {
5372
5385
  }
5373
5386
  const _vueI18n = this.$i18n;
5374
5387
  /* istanbul ignore if */
5375
- if (this.$el &&
5376
- this.$el.__VUE_I18N__) {
5388
+ if (instance.__VUE_I18N__) {
5377
5389
  if (this.__v_emitter) {
5378
5390
  this.__v_emitter.off('*', addTimelineEvent);
5379
5391
  delete this.__v_emitter;
5380
5392
  }
5381
5393
  if (this.$i18n) {
5382
5394
  _vueI18n.__disableEmitter && _vueI18n.__disableEmitter();
5383
- delete this.$el.__VUE_I18N__;
5395
+ delete instance.__VUE_I18N__;
5384
5396
  }
5385
5397
  }
5386
5398
  delete this.$t;
@@ -6055,8 +6067,8 @@ function setupLifeCycle(i18n, target, composer) {
6055
6067
  let emitter = null;
6056
6068
  onMounted(() => {
6057
6069
  // inject composer instance to DOM for intlify-devtools
6058
- if (target.vnode.el) {
6059
- target.vnode.el.__VUE_I18N__ = composer;
6070
+ {
6071
+ target.__VUE_I18N__ = composer;
6060
6072
  emitter = createEmitter();
6061
6073
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6062
6074
  const _composer = composer;
@@ -6068,11 +6080,10 @@ function setupLifeCycle(i18n, target, composer) {
6068
6080
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6069
6081
  const _composer = composer;
6070
6082
  // remove composer instance from DOM for intlify-devtools
6071
- if (target.vnode.el &&
6072
- target.vnode.el.__VUE_I18N__) {
6083
+ {
6073
6084
  emitter && emitter.off('*', addTimelineEvent);
6074
6085
  _composer[DisableEmitter] && _composer[DisableEmitter]();
6075
- delete target.vnode.el.__VUE_I18N__;
6086
+ delete target.__VUE_I18N__;
6076
6087
  }
6077
6088
  i18n.__deleteInstance(target);
6078
6089
  // dispose extended resources