vite build ends up with "[intlify] Not found '...' key in '...' locale messages."
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- javascript, typescript
调研方向
先从 index.js 中的 messages 对象和 App.vue 中的 $t 调用开始,然后使用提供的 vite.config.js 运行 npm run dev 重现报告。确认示例显示预期的本地化字符串,且没有缺少键的警告;同时使用 npm run build 验证结果。
由索引模型根据 Issue 内容生成。
描述
Setting up vite with vite-plugin-vue-i18n according to the documentation followed by
npm run dev and navigating to localhost:<port> Will always display "message" and the console tells me
[intlify] Not found 'message' key in 'ja' locale messages.
[intlify] Fall back to translate 'message' key with 'en' locale.
[intlify] Not found 'message' key in 'en' locale messages.
Both in a "full-scale" application and the minimal example below.
Expected behavior
Localized message string.
Reproduction
package.json
{
"name": "my-project",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"@heroicons/vue": "^1.0.6",
"@tailwindcss/forms": "^0.5.2",
"tailwindcss": "^3.0.24",
"vue": "^3.2.37",
"vue-i18n": "^9.1.10"
},
"devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^5.0.0",
"@vitejs/plugin-vue": "^3.0.0",
"@vue/cli-service": "^5.0.8",
"@vue/compiler-sfc": "^3.2.37",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"vite": "3.0.0",
"vue-router": "^4.1.2"
}
}
vite.config.js
import { fileURLToPath, URL } from 'url'
const { defineConfig } = require('vite')
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
export default defineConfig({
plugins: [
vue(),
vueI18n({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// include: path.resolve(__dirname, './path/to/src/locales/**')
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
})
index.js
import './index.css'
import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
import App from './App.vue'
const messages = {
en: {
message: {
hello: 'hello world'
}
},
ja: {
message: {
hello: 'こんにちは、世界'
}
}
}
const i18n = createI18n({
globalInjection: true,
locale: 'ja',
fallbackLocale: 'en',
messages,
})
const app = createApp(App);
app.use(i18n).mount('#app');
App.vue
<script setup>
</script>
<template>
<div class="flex justify-center text-3xl py-16">{{ $t('message') }}</div>
</template>
<script>
export default {}
</script>
Issue Package
vite-plugin-vue-i18n
System Info
System:
OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
Memory: 11.71 GB / 14.86 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.6.0 - /usr/bin/node
npm: 8.14.0 - /usr/bin/npm
Browsers:
Chromium: 103.0.5060.53
Firefox: 102.0.1
npmPackages:
@intlify/vite-plugin-vue-i18n: ^5.0.0 => 5.0.0
vite: 3.0.0 => 3.0.0
vue: ^3.2.37 => 3.2.37
vue-i18n: ^9.1.10 => 9.1.10
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines.
- Read the README
- 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 Discussion.
- 主要语言
- TypeScript
- 星标
- 270
- 派生
- 46
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
intlify/bundle-tools 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
intlify/bundle-tools#612 ·
-
难度 3/5 1-2 天 新手友好度 72/100
intlify/bundle-tools#611 ·
-
难度 4/5 3-5 天 新手友好度 52/100
intlify/bundle-tools#600 · 5 条评论 ·
-
Locale files are never invalidated on Vite 8 — dev server serves stale translations until restart未关闭
难度 4/5 3-5 天 新手友好度 68/100
intlify/bundle-tools#599 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
intlify/bundle-tools#533 ·
查看 intlify/bundle-tools 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
callstackincubator/rozenite#518 ·
维护者通常 1 天内回复
-
Area/Workflow Priority/Blocker Type/Bug
难度 2/5 1-3 小时 新手友好度 76/100
wso2/product-integrator#2622 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
area:bash bug has repro platform:macos
难度 2/5 1-3 小时 新手友好度 78/100
anthropics/claude-code#98644 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
allure-framework/allure-js#1603 ·
维护者通常 1 天内回复