Skip to content

Commit

Permalink
fix: i18n vite plugin error during nuxt warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
CharleeWa committed Nov 27, 2024
1 parent 8dd029d commit 5395617
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/plugins/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Locale as TypeLocale } from '#i18n'
import { Locale } from 'vant'
import enUS from 'vant/es/locale/lang/en-US'
import zhCN from 'vant/es/locale/lang/zh-CN'

type AppLocale = 'zh-CN' | 'en-US'

export default defineNuxtPlugin(() => {
// 载入 vant 语言包
Locale.use('zh-CN', zhCN)
Expand All @@ -16,7 +15,7 @@ export default defineNuxtPlugin(() => {
const lang = localStorage.getItem('lang')

if (lang) {
setLocale(lang as AppLocale)
setLocale(lang as TypeLocale)
Locale.use(lang)
}
else {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"inflight": "1",
"npmlog": "5",
"rimraf": "3"
},
"patchedDependencies": {
"@nuxtjs/[email protected]": "patches/@[email protected]"
}
},
"simple-git-hooks": {
Expand Down
13 changes: 13 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dist/module.mjs b/dist/module.mjs
index b6def32f8bde5516e6ee0a25f153b01803f55683..897b44120533fdb74b33d9d4dff1d21b910073ca 100644
--- a/dist/module.mjs
+++ b/dist/module.mjs
@@ -1462,7 +1462,7 @@ async function extendBundler({ options: nuxtOptions }, nuxt) {
fullInstall: nuxtOptions.bundle.fullInstall,
onlyLocales: nuxtOptions.bundle.onlyLocales,
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
- optimizeTranslationDirective: true,
+ optimizeTranslationDirective: false,
strictMessage: nuxtOptions.compilation.strictMessage,
escapeHtml: nuxtOptions.compilation.escapeHtml,
defaultSFCLang: nuxtOptions.customBlocks.defaultSFCLang,
9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5395617

Please sign in to comment.