@@ -19,7 +19,8 @@ import {
1919 getLocaleMessages ,
2020 createComposer ,
2121 EnableEmitter ,
22- DisableEmitter
22+ DisableEmitter ,
23+ InejctWithOption
2324} from './composer'
2425import { createVueI18n } from './legacy'
2526import { I18nWarnCodes , getWarnMessage } from './warnings'
@@ -598,7 +599,8 @@ export function useI18n<
598599 }
599600
600601 if ( scope === 'parent' ) {
601- let composer = getComposer ( i18n , instance )
602+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
603+ let composer = getComposer ( i18n , instance , ( options as any ) . __useComponent )
602604 if ( composer == null ) {
603605 if ( __DEV__ ) {
604606 warn ( getWarnMessage ( I18nWarnCodes . NOT_FOUND_PARENT_SCOPE ) )
@@ -666,7 +668,8 @@ function getComposer<
666668 Legacy extends boolean
667669> (
668670 i18n : I18n < Messages , DateTimeFormats , NumberFormats , Legacy > ,
669- target : ComponentInternalInstance
671+ target : ComponentInternalInstance ,
672+ useComponent = false
670673) : Composer < Messages , DateTimeFormats , NumberFormats > | null {
671674 let composer : Composer < Messages , DateTimeFormats , NumberFormats > | null = null
672675 const root = target . root
@@ -696,6 +699,10 @@ function getComposer<
696699 VueI18nInternal < Messages , DateTimeFormats , NumberFormats > )
697700 . __composer as Composer < Messages , DateTimeFormats , NumberFormats >
698701 }
702+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
703+ if ( useComponent && ! ( composer as any ) [ InejctWithOption ] ) {
704+ composer = null
705+ }
699706 }
700707 if ( composer != null ) {
701708 break
0 commit comments