Skip to content

Commit f72a1bb

Browse files
authored
fix(legacy): allow mutil i18n instance for bridge (#983)
1 parent 396b715 commit f72a1bb

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

packages/vue-i18n-core/src/i18n.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ declare module 'vue' {
9393

9494
// for bridge
9595
let _legacyVueI18n: any = /* #__PURE__*/ null // eslint-disable-line @typescript-eslint/no-explicit-any
96-
let _legacyI18n: I18n | null = /* #__PURE__*/ null // eslint-disable-line @typescript-eslint/no-explicit-any
9796

9897
/**
9998
* I18n Options for `createI18n`
@@ -471,11 +470,6 @@ export function createI18n<
471470
export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
472471
type _I18n = I18n & I18nInternal
473472

474-
if (__BRIDGE__ && _legacyI18n) {
475-
__DEV__ &&
476-
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORT_MULTI_I18N_INSTANCE))
477-
return _legacyI18n
478-
}
479473
if (__BRIDGE__) {
480474
_legacyVueI18n = VueI18nLegacy
481475
}
@@ -675,7 +669,6 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
675669
key =>
676670
Object.defineProperty(i18n, key, { value: (methodMap as any)[key] }) // eslint-disable-line @typescript-eslint/no-explicit-any
677671
)
678-
_legacyI18n = i18n
679672
return i18n
680673
}
681674
}
@@ -783,7 +776,7 @@ export function useI18n<
783776
}
784777

785778
if (__BRIDGE__) {
786-
if (_legacyVueI18n == null || _legacyI18n == null) {
779+
if (_legacyVueI18n == null) {
787780
throw createI18nError(I18nErrorCodes.NOT_INSLALLED)
788781
}
789782
}
@@ -936,10 +929,7 @@ function getI18nInstance(instance: ComponentInternalInstance): I18n {
936929
if (vm == null) {
937930
throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR)
938931
}
939-
let i18n = (vm as any)._i18nBridgeRoot // eslint-disable-line @typescript-eslint/no-explicit-any
940-
if (!i18n) {
941-
i18n = _legacyI18n
942-
}
932+
const i18n = (vm as any)._i18nBridgeRoot // eslint-disable-line @typescript-eslint/no-explicit-any
943933
/* istanbul ignore if */
944934
if (!i18n) {
945935
throw createI18nError(I18nErrorCodes.NOT_INSLALLED)

packages/vue-i18n-core/src/warnings.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export const I18nWarnCodes = {
1111
NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc(), // 10
1212
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
1313
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
14-
NOT_FOUND_PARENT_SCOPE: inc(), // 13
15-
NOT_SUPPORT_MULTI_I18N_INSTANCE: inc() // 14
14+
NOT_FOUND_PARENT_SCOPE: inc() // 13
1615
} as const
1716

1817
type I18nWarnCodes = typeof I18nWarnCodes[keyof typeof I18nWarnCodes]
@@ -24,8 +23,7 @@ export const warnMessages: { [code: number]: string } = {
2423
[I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`,
2524
[I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`,
2625
[I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`,
27-
[I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`,
28-
[I18nWarnCodes.NOT_SUPPORT_MULTI_I18N_INSTANCE]: `Not support multi i18n instance.`
26+
[I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`
2927
}
3028

3129
export function getWarnMessage(

0 commit comments

Comments
 (0)