-
-
Notifications
You must be signed in to change notification settings - Fork 377
Closed
Labels
Type: ImprovementIncludes backwards-compatible fixesIncludes backwards-compatible fixes🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressingPriority 2: nothing is broken but it's worth addressing
Description
Reporting a bug?
Messages defined in an SFC that link to messages defined in the root context are displayed when NODE_ENV is "development"
but are not displayed when NODE_ENV is "production"
.
I believe the difference in behavior is caused by the setting of fallbackContext
when NODE_ENV is "development"
.
Code as of writing in wrapWithDeps
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
try {
setAdditionalMeta(getMetaInfo())
if (!_isGlobal) {
_context.fallbackContext = __root
? (getFallbackContext() as any)
: undefined
}
ret = fn(_context)
} finally {
setAdditionalMeta(null)
if (!_isGlobal) {
_context.fallbackContext = undefined
}
}
} else {
ret = fn(_context)
}
Expected behavior
Messages created at createI18n
time should be available for use to all SFCs.
Common and shared messages should not need to be defined multiple times. Examples of those messages include:
- name
- description
- submit
- cancel
Reproduction
Step 1 - Code Changes
In vue-i18n-next
's examples/web-components
project make the following changes:
main.ts
Alter the createI18n
argument to include the following messages:
messages: {
en: {
test: 'Test Message...'
}
}
HelloBlock.ce.vue
Alter the <i18n>
block to be the following:
<i18n>
{
"en": {
"world": "@:test The world!"
},
"ja": {
"world": "ザ・ワールド"
}
}
</i18n>
Step 2 - Expected behavior when NODE_ENV is "development"
- Ensure
NODE_ENV
environment variable isdevelopment
. - From
examples/web-components
runpnpm dev
and navigate to the application - Validate that "Test Message... The world!" is rendered (see screenshot)

Step 3 - Buggy behavior when NODE_ENV is "production"
- Ensure
NODE_ENV
environment variable isproduction
. - From
examples/web-components
runpnpm dev
and navigate to the application - Expect that "Test Message... The world!" is rendered, but it is just "The world!" (see screenshot)

System Info
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 Intel(R) Xeon(R) E-2134 CPU @ 3.50GHz
Memory: 11.41 GB / 31.88 GB
Binaries:
Node: 20.0.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
Yarn: 1.22.19 - ~\scoop\apps\nvm\current\nodejs\nodejs\yarn.CMD
npm: 9.6.4 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
pnpm: 8.6.5 - ~\scoop\shims\pnpm.EXE
Browsers:
Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.58)
Internet Explorer: 11.0.22621.1
npmPackages:
@intlify/vite-plugin-vue-i18n: ^2.4.0 => 2.4.0
@vitejs/plugin-vue: ^4.2.0 => 4.2.3
@vue/compiler-sfc: ^3.3.4 => 3.3.4
vite: ^4.3.0 => 4.3.9
vue: ^3.3.4 => 3.3.4
vue-i18n: workspace:* => 9.3.0-beta.19
vue-tsc: ^1.6.5 => 1.6.5
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussions
Metadata
Metadata
Assignees
Labels
Type: ImprovementIncludes backwards-compatible fixesIncludes backwards-compatible fixes🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressingPriority 2: nothing is broken but it's worth addressing