Skip to content

Commit 5395617

Browse files
committed
fix: i18n vite plugin error during nuxt warmup
Ref: nuxt-modules/i18n#3241
1 parent 8dd029d commit 5395617

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

app/plugins/i18n.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import type { Locale as TypeLocale } from '#i18n'
12
import { Locale } from 'vant'
23
import enUS from 'vant/es/locale/lang/en-US'
34
import zhCN from 'vant/es/locale/lang/zh-CN'
45

5-
type AppLocale = 'zh-CN' | 'en-US'
6-
76
export default defineNuxtPlugin(() => {
87
// 载入 vant 语言包
98
Locale.use('zh-CN', zhCN)
@@ -16,7 +15,7 @@ export default defineNuxtPlugin(() => {
1615
const lang = localStorage.getItem('lang')
1716

1817
if (lang) {
19-
setLocale(lang as AppLocale)
18+
setLocale(lang as TypeLocale)
2019
Locale.use(lang)
2120
}
2221
else {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
"inflight": "1",
5555
"npmlog": "5",
5656
"rimraf": "3"
57+
},
58+
"patchedDependencies": {
59+
"@nuxtjs/i18n@9.1.0": "patches/@nuxtjs__i18n@9.1.0.patch"
5760
}
5861
},
5962
"simple-git-hooks": {

patches/@nuxtjs__i18n@9.1.0.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dist/module.mjs b/dist/module.mjs
2+
index b6def32f8bde5516e6ee0a25f153b01803f55683..897b44120533fdb74b33d9d4dff1d21b910073ca 100644
3+
--- a/dist/module.mjs
4+
+++ b/dist/module.mjs
5+
@@ -1462,7 +1462,7 @@ async function extendBundler({ options: nuxtOptions }, nuxt) {
6+
fullInstall: nuxtOptions.bundle.fullInstall,
7+
onlyLocales: nuxtOptions.bundle.onlyLocales,
8+
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
9+
- optimizeTranslationDirective: true,
10+
+ optimizeTranslationDirective: false,
11+
strictMessage: nuxtOptions.compilation.strictMessage,
12+
escapeHtml: nuxtOptions.compilation.escapeHtml,
13+
defaultSFCLang: nuxtOptions.customBlocks.defaultSFCLang,

pnpm-lock.yaml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)