Skip to content

Commit a84630f

Browse files
committed
fix: empty i18n options not loading vue-i18n config file (#3093)
1 parent e84d530 commit a84630f

File tree

10 files changed

+2701
-662
lines changed

10 files changed

+2701
-662
lines changed

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
"@intlify/unplugin-vue-i18n": "^3.0.1",
8585
"@intlify/utils": "^0.12.0",
8686
"@miyaneee/rollup-plugin-json5": "^1.2.0",
87-
"@nuxt/kit": "^3.12.4",
87+
"@nuxt/kit": "^3.13.1",
8888
"@rollup/plugin-yaml": "^4.1.2",
89-
"@vue/compiler-sfc": "^3.4.37",
89+
"@vue/compiler-sfc": "^3.5.4",
9090
"debug": "^4.3.5",
9191
"defu": "^6.1.2",
9292
"estree-walker": "^3.0.3",
@@ -100,15 +100,15 @@
100100
"ufo": "^1.3.1",
101101
"unplugin": "^1.10.1",
102102
"vue-i18n": "^9.9.0",
103-
"vue-router": "^4.4.0"
103+
"vue-router": "^4.4.4"
104104
},
105105
"devDependencies": {
106106
"@babel/parser": "^7.24.7",
107107
"@babel/plugin-syntax-import-assertions": "^7.24.7",
108108
"@babel/types": "^7.24.7",
109109
"@eslint/js": "9.5.0",
110110
"@nuxt/module-builder": "^0.8.3",
111-
"@nuxt/schema": "^3.12.4",
111+
"@nuxt/schema": "^3.13.1",
112112
"@types/debug": "^4.1.9",
113113
"@types/eslint": "^8.56.6",
114114
"@unhead/vue": "^1.8.8",
@@ -128,10 +128,10 @@
128128
"lint-staged": "^15.2.7",
129129
"nitropack": "^2.9.6",
130130
"npm-run-all2": "^6.2.0",
131-
"nuxt": "^3.12.4",
131+
"nuxt": "^3.13.1",
132132
"ofetch": "^1.3.4",
133-
"playwright": "^1.38.1",
134133
"pkg-pr-new": "^0.0.20",
134+
"playwright": "^1.38.1",
135135
"prettier": "^3.3.2",
136136
"ts-essentials": "^9.4.2",
137137
"typescript": "^5.5.2",
@@ -140,7 +140,7 @@
140140
"undici": "^6.19.2",
141141
"unhead": "^1.8.8",
142142
"vitest": "^1.6.0",
143-
"vue": "^3.4.37"
143+
"vue": "^3.5.4"
144144
},
145145
"lint-staged": {
146146
"*.{json,md,yml}": [

pnpm-lock.yaml

+2,637-652
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specs/basic_usage.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ describe('basic usage', async () => {
8989
// @ts-ignore
9090
delete x.components[component].__file
9191
}
92+
// @ts-ignore
93+
delete x.mods
9294
return x
9395
})
9496
expect(localeRoute).toMatchInlineSnapshot(

specs/empty_options.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect, describe } from 'vitest'
2+
import { fileURLToPath } from 'node:url'
3+
import { setup } from './utils'
4+
import { renderPage } from './helper'
5+
6+
await setup({
7+
rootDir: fileURLToPath(new URL(`./fixtures/empty_options`, import.meta.url)),
8+
browser: true
9+
})
10+
11+
describe('inline options are handled correctly', async () => {
12+
test('inline options are handled correctly', async () => {
13+
const { page } = await renderPage('/')
14+
15+
const text = await page.locator('#text-div').innerHTML()
16+
expect(text).toMatchInlineSnapshot(`"Hi from @nuxtjs/i18n: from the en locale"`)
17+
})
18+
})

specs/fixtures/empty_options/app.vue

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div id="text-div">Hi from @nuxtjs/i18n: {{ $t('hello') }}</div>
3+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default defineI18nConfig(() => ({
2+
legacy: false,
3+
locale: 'en',
4+
messages: {
5+
en: {
6+
hello: 'from the en locale'
7+
}
8+
}
9+
}))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://nuxt.com/docs/guide/directory-structure/nuxt.config
2+
export default defineNuxtConfig({
3+
compatibilityDate: '2024-04-03',
4+
modules: ['@nuxtjs/i18n']
5+
})
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "nuxt3-test-empty-options",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxi build",
7+
"dev": "nuxi dev",
8+
"generate": "nuxi generate",
9+
"preview": "nuxi preview"
10+
},
11+
"devDependencies": {
12+
"@nuxtjs/i18n": "latest",
13+
"nuxt": "latest"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"extends": "./.nuxt/tsconfig.json"
4+
}

src/layers.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ export async function resolveLayerVueI18nConfigInfo(options: NuxtI18nOptions) {
166166

167167
const resolveArr = nuxt.options._layers.map(async layer => {
168168
const i18n = getLayerI18n(layer)
169-
if (i18n == null) return undefined
170-
171-
const res = await resolveVueI18nConfigInfo(resolveI18nDir(layer, i18n, true), i18n.vueI18n)
169+
const res = await resolveVueI18nConfigInfo(resolveI18nDir(layer, i18n || {}, true), i18n?.vueI18n)
172170

173171
if (res == null && i18n?.vueI18n != null) {
174172
logger.warn(

0 commit comments

Comments
 (0)