Skip to content

Commit 81ad9fe

Browse files
authored
fix: root context message availability for linked messages in SFCs on productin (#1477)
closes #1444
1 parent 6777e3d commit 81ad9fe

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ export interface ComposerInternalOptions<
576576
export interface ComposerTranslation<
577577
Messages extends Record<string, any> = {},
578578
Locales = 'en-US',
579-
DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
579+
DefinedLocaleMessage extends
580+
RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
580581
C = IsEmptyObject<DefinedLocaleMessage> extends false
581582
? PickupPaths<{
582583
[K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
@@ -920,7 +921,8 @@ export interface ComposerResolveLocaleMessageTranslation<Locales = 'en-US'> {
920921
export interface ComposerDateTimeFormatting<
921922
DateTimeFormats extends Record<string, any> = {},
922923
Locales = 'en-US',
923-
DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
924+
DefinedDateTimeFormat extends
925+
RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
924926
C = IsEmptyObject<DefinedDateTimeFormat> extends false
925927
? PickupFormatPathKeys<{
926928
[K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
@@ -1009,7 +1011,8 @@ export interface ComposerDateTimeFormatting<
10091011
export interface ComposerNumberFormatting<
10101012
NumberFormats extends Record<string, any> = {},
10111013
Locales = 'en-US',
1012-
DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>,
1014+
DefinedNumberFormat extends
1015+
RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>,
10131016
C = IsEmptyObject<DefinedNumberFormat> extends false
10141017
? PickupFormatPathKeys<{
10151018
[K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
@@ -2083,23 +2086,23 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
20832086
trackReactivityValues() // track reactive dependency
20842087
// NOTE: experimental !!
20852088
let ret: unknown
2086-
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
2087-
try {
2089+
try {
2090+
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
20882091
setAdditionalMeta(getMetaInfo())
2089-
if (!_isGlobal) {
2090-
_context.fallbackContext = __root
2091-
? (getFallbackContext() as any)
2092-
: undefined
2093-
}
2094-
ret = fn(_context)
2095-
} finally {
2096-
setAdditionalMeta(null)
2097-
if (!_isGlobal) {
2098-
_context.fallbackContext = undefined
2099-
}
21002092
}
2101-
} else {
2093+
if (!_isGlobal) {
2094+
_context.fallbackContext = __root
2095+
? (getFallbackContext() as any)
2096+
: undefined
2097+
}
21022098
ret = fn(_context)
2099+
} finally {
2100+
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
2101+
setAdditionalMeta(null)
2102+
}
2103+
if (!_isGlobal) {
2104+
_context.fallbackContext = undefined
2105+
}
21032106
}
21042107
if (isNumber(ret) && ret === NOT_REOSLVED) {
21052108
const [key, arg2] = argumentParser()

0 commit comments

Comments
 (0)