diff --git a/specs/basic_usage.spec.ts b/specs/basic_usage.spec.ts
index 3e5f59597..de7d92164 100644
--- a/specs/basic_usage.spec.ts
+++ b/specs/basic_usage.spec.ts
@@ -601,4 +601,10 @@ describe('basic usage', async () => {
await restore()
})
+
+ test('(#2094) vue-i18n messages are loaded from config exported as variable', async () => {
+ const { page } = await renderPage('/')
+
+ expect(await getText(page, '#issue-2094')).toEqual('Exporting using variable identifier works!')
+ })
})
diff --git a/specs/fixtures/basic/pages/index.vue b/specs/fixtures/basic/pages/index.vue
index c6f6613ea..7b9db292b 100644
--- a/specs/fixtures/basic/pages/index.vue
+++ b/specs/fixtures/basic/pages/index.vue
@@ -69,5 +69,9 @@ useHead(() => ({
go to defineI18nRoute(false)
+
+ {{ localePath('/test-route?foo=bar') }}
+ {{ localePath('/i-dont-exist?foo=bar') }}
+
diff --git a/specs/fixtures/basic_usage/pages/index.vue b/specs/fixtures/basic_usage/pages/index.vue
index f4fdbfee6..7cb9e6828 100644
--- a/specs/fixtures/basic_usage/pages/index.vue
+++ b/specs/fixtures/basic_usage/pages/index.vue
@@ -232,6 +232,9 @@ useHead({
{{ $t('moduleLayerBaseKey') }}
{{ $t('moduleLayerBaseKeyNamed', { name: 'bar' }) }}
+
+ {{ $t('variableExportedI18nConfig') }}
+
{{ localeProperties }}
diff --git a/specs/fixtures/issues/2020/app.vue b/specs/fixtures/issues/2020/app.vue
deleted file mode 100644
index 2b1be0907..000000000
--- a/specs/fixtures/issues/2020/app.vue
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/specs/fixtures/issues/2020/i18n.config.ts b/specs/fixtures/issues/2020/i18n.config.ts
deleted file mode 100644
index 2ce25f1ac..000000000
--- a/specs/fixtures/issues/2020/i18n.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export default defineI18nConfig(() => ({
- legacy: false,
- locale: 'en',
- messages: {
- en: {
- welcome: 'Welcome'
- },
- fr: {
- welcome: 'Bienvenue'
- }
- }
-}))
diff --git a/specs/fixtures/issues/2020/nuxt.config.ts b/specs/fixtures/issues/2020/nuxt.config.ts
deleted file mode 100644
index bbf21fa01..000000000
--- a/specs/fixtures/issues/2020/nuxt.config.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// https://v3.nuxtjs.org/api/configuration/nuxt.config
-export default defineNuxtConfig({
- modules: ['@nuxtjs/i18n'],
-
- i18n: {
- vueI18n: './i18n.config.ts', // if you are using custom path, default
- locales: [
- {
- code: 'fr',
- name: 'Français',
- iso: 'fr-BE'
- },
- {
- code: 'en',
- name: 'English',
- iso: 'en-US'
- }
- ],
- defaultLocale: 'fr',
- strategy: 'prefix'
- }
-})
diff --git a/specs/fixtures/issues/2020/package.json b/specs/fixtures/issues/2020/package.json
deleted file mode 100644
index 8e1ab0419..000000000
--- a/specs/fixtures/issues/2020/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "nuxt3-test-issues-2020",
- "private": true,
- "scripts": {
- "build": "nuxt build",
- "dev": "nuxt dev",
- "generate": "nuxt generate",
- "preview": "nuxt preview"
- },
- "devDependencies": {
- "@nuxtjs/i18n": "latest",
- "nuxt": "latest"
- }
-}
diff --git a/specs/fixtures/issues/2020/pages/index.vue b/specs/fixtures/issues/2020/pages/index.vue
deleted file mode 100644
index 200a20b2c..000000000
--- a/specs/fixtures/issues/2020/pages/index.vue
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
{{ $t('welcome') }}
-
Existing path
-
- - Path:
- - {{ path }}
- - Localised path:
- - {{ localePath(path) }}
- - Router resolve from string:
- - {{ resolvedPathFromString }}
- - Router resolve from object:
- - {{ resolvedPathFromObject }}
-
-
-
Unexisting path
-
- - Path:
- - {{ wrong_path }}
- - Localised path:
- - {{ localePath(wrong_path) }}
- - Router resolve from string:
- - {{ resolvedWrongPathFromString }}
- - Router resolve from object:
- - {{ resolvedWrongPathFromObject }}
-
-
-
-
-
diff --git a/specs/fixtures/issues/2020/pages/some-route.vue b/specs/fixtures/issues/2020/pages/some-route.vue
deleted file mode 100644
index 93831cd6f..000000000
--- a/specs/fixtures/issues/2020/pages/some-route.vue
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
Some route
-
-
diff --git a/specs/fixtures/issues/2094/app.vue b/specs/fixtures/issues/2094/app.vue
deleted file mode 100644
index 2b1be0907..000000000
--- a/specs/fixtures/issues/2094/app.vue
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/specs/fixtures/issues/2094/i18n.config.ts b/specs/fixtures/issues/2094/i18n.config.ts
deleted file mode 100644
index b40ff88ed..000000000
--- a/specs/fixtures/issues/2094/i18n.config.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-const config = defineI18nConfig(() => {
- return {
- legacy: false,
- locale: 'ja',
- messages: {
- ja: {
- big: 'こんにちは,'.repeat(10)
- }
- }
- }
-})
-
-export default config
diff --git a/specs/fixtures/issues/2094/nuxt.config.ts b/specs/fixtures/issues/2094/nuxt.config.ts
deleted file mode 100644
index b11432890..000000000
--- a/specs/fixtures/issues/2094/nuxt.config.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-// https://nuxt.com/docs/api/configuration/nuxt-config
-export default defineNuxtConfig({
- modules: ['@nuxtjs/i18n'],
-
- i18n: {
- defaultLocale: 'ja',
- locales: [
- {
- code: 'ja',
- iso: 'ja-JP',
- name: 'Japanese'
- }
- ]
- }
-})
diff --git a/specs/fixtures/issues/2094/package.json b/specs/fixtures/issues/2094/package.json
deleted file mode 100644
index e98685246..000000000
--- a/specs/fixtures/issues/2094/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "nuxt3-test-issues-2000",
- "private": true,
- "type": "module",
- "scripts": {
- "build": "nuxt build",
- "dev": "nuxt dev",
- "generate": "nuxt generate",
- "start": "node .output/server/index.mjs"
- },
- "devDependencies": {
- "@nuxtjs/i18n": "latest",
- "nuxt": "latest"
- }
-}
diff --git a/specs/fixtures/issues/2094/pages/index.vue b/specs/fixtures/issues/2094/pages/index.vue
deleted file mode 100644
index f5f42e238..000000000
--- a/specs/fixtures/issues/2094/pages/index.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- {{ t('big') }}
-
diff --git a/specs/fixtures/issues/2132/app.vue b/specs/fixtures/issues/2132/app.vue
deleted file mode 100644
index 8e7f33e90..000000000
--- a/specs/fixtures/issues/2132/app.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/specs/fixtures/issues/2132/i18n.config.ts b/specs/fixtures/issues/2132/i18n.config.ts
deleted file mode 100644
index 39af57191..000000000
--- a/specs/fixtures/issues/2132/i18n.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export default {
- legacy: false,
- fallbackLocale: 'en',
- messages: {
- en: {
- msg: 'English message',
- },
- ja: {
- msg: '日本語のメッセージ',
- },
- },
-};
diff --git a/specs/fixtures/issues/2132/nuxt.config.ts b/specs/fixtures/issues/2132/nuxt.config.ts
deleted file mode 100644
index eb86eb00b..000000000
--- a/specs/fixtures/issues/2132/nuxt.config.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-export default defineNuxtConfig({
- ssr: true,
- components: true,
-
- modules: ['@nuxtjs/i18n'],
-
- i18n: {
- locales: [
- {
- code: 'en',
- iso: 'en',
- name: 'English'
- },
- {
- code: 'ja',
- iso: 'ja-JP',
- name: '日本語'
- }
- ],
- strategy: 'prefix',
- defaultLocale: 'en',
- // debug: true,
- detectBrowserLanguage: {
- useCookie: true,
- cookieSecure: true,
- fallbackLocale: 'en',
- redirectOn: 'no prefix'
- }
- }
-})
diff --git a/specs/fixtures/issues/2132/package.json b/specs/fixtures/issues/2132/package.json
deleted file mode 100644
index eeeb75362..000000000
--- a/specs/fixtures/issues/2132/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "nuxt3-test-issues-2132",
- "private": true,
- "type": "module",
- "scripts": {
- "build": "nuxt build",
- "dev": "nuxt dev",
- "generate": "nuxt generate",
- "start": "node .output/server/index.mjs"
- },
- "devDependencies": {
- "@nuxtjs/i18n": "latest",
- "nuxt": "latest"
- }
-}
diff --git a/specs/fixtures/issues/2132/pages/index.vue b/specs/fixtures/issues/2132/pages/index.vue
deleted file mode 100644
index 0edcd6527..000000000
--- a/specs/fixtures/issues/2132/pages/index.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- {{ $t('msg') }}
-
-
-
-
diff --git a/specs/fixtures/layers/layer-vueI18n-options/layer-simple/i18n.config.ts b/specs/fixtures/layers/layer-vueI18n-options/layer-simple/i18n.config.ts
index 5b4908446..11476561d 100644
--- a/specs/fixtures/layers/layer-vueI18n-options/layer-simple/i18n.config.ts
+++ b/specs/fixtures/layers/layer-vueI18n-options/layer-simple/i18n.config.ts
@@ -1,4 +1,7 @@
-export default {
+import type { I18nOptions } from 'vue-i18n'
+
+// (#2094) export using variable and typescript
+const config: I18nOptions = {
fallbackLocale: 'en',
messages: {
fr: {
@@ -12,7 +15,8 @@ export default {
en: {
aboutSite: 'About this site',
snakeCaseText: "@.snakeCase:{'aboutSite'}",
- pascalCaseText: "@.pascalCase:{'aboutSite'}"
+ pascalCaseText: "@.pascalCase:{'aboutSite'}",
+ variableExportedI18nConfig: 'Exporting using variable identifier works!'
}
},
modifiers: {
@@ -24,3 +28,5 @@ export default {
.join('')
}
}
+
+export default config
diff --git a/specs/issues/2020.spec.ts b/specs/issues/2020.spec.ts
deleted file mode 100644
index 5fe461882..000000000
--- a/specs/issues/2020.spec.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { test, expect, describe } from 'vitest'
-import { fileURLToPath } from 'node:url'
-import { URL } from 'node:url'
-import { setup, url, createPage } from '../utils'
-import { getText } from '../helper'
-
-describe('#2020', async () => {
- await setup({
- rootDir: fileURLToPath(new URL(`../fixtures/issues/2020`, import.meta.url))
- })
-
- test('pass query parameter', async () => {
- const home = url('/')
- const page = await createPage()
- await page.goto(home)
-
- const existingPath = await getText(page, '#existing')
- const unexistingPath = await getText(page, '#unexisting')
-
- expect(existingPath).toBe('/fr/some-route?foo=bar')
- expect(unexistingPath).toBe('/i-dont-exist?foo=bar')
- })
-})
diff --git a/specs/issues/2094.spec.ts b/specs/issues/2094.spec.ts
deleted file mode 100644
index fa638867c..000000000
--- a/specs/issues/2094.spec.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { test, describe, expect } from 'vitest'
-import { fileURLToPath } from 'node:url'
-import { setup } from '../utils'
-import { getText, renderPage } from '../helper'
-
-describe('#2094', async () => {
- await setup({
- rootDir: fileURLToPath(new URL(`../fixtures/issues/2094`, import.meta.url)),
- browser: true
- })
-
- test('vue-i18n messages are loaded from config exported as variable', async () => {
- const { page } = await renderPage('/')
-
- expect(await getText(page, '#render')).toEqual('こんにちは,'.repeat(10))
- })
-})
diff --git a/specs/issues/2132.spec.ts b/specs/issues/2132.spec.ts
deleted file mode 100644
index 4d4724efc..000000000
--- a/specs/issues/2132.spec.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { test, describe, expect } from 'vitest'
-import { fileURLToPath } from 'node:url'
-import { setup } from '../utils'
-import { getText, gotoPath, renderPage } from '../helper'
-
-describe('#2132', async () => {
- await setup({
- rootDir: fileURLToPath(new URL(`../fixtures/issues/2132`, import.meta.url)),
- browser: true
- })
-
- test('should be work redirectOn "no prefix"', async () => {
- const { page } = await renderPage('/', { locale: 'ja' })
-
- expect(await getText(page, '#msg')).toEqual('日本語のメッセージ')
-
- await gotoPath(page, '/en')
- expect(await getText(page, '#msg')).toEqual('English message')
- })
-})
diff --git a/specs/routing_strategies/prefix.spec.ts b/specs/routing_strategies/prefix.spec.ts
index 712116c1c..10a57be22 100644
--- a/specs/routing_strategies/prefix.spec.ts
+++ b/specs/routing_strategies/prefix.spec.ts
@@ -1,7 +1,7 @@
import { describe, test, expect } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, url, fetch } from '../utils'
-import { getText, getData, renderPage, waitForURL, startServerWithRuntimeConfig } from '../helper'
+import { getText, getData, renderPage, waitForURL, startServerWithRuntimeConfig, gotoPath } from '../helper'
import type { Response } from 'playwright'
@@ -152,4 +152,34 @@ describe('strategy: prefix', async () => {
await restore()
})
+
+ test("(#2132) should redirect on root url with `redirectOn: 'no prefix'`", async () => {
+ const restore = await startServerWithRuntimeConfig({
+ public: {
+ i18n: {
+ detectBrowserLanguage: {
+ useCookie: true,
+ cookieSecure: true,
+ fallbackLocale: 'en',
+ redirectOn: 'no prefix'
+ }
+ }
+ }
+ })
+
+ const { page } = await renderPage('/', { locale: 'fr' })
+ expect(await getText(page, '#home-header')).toEqual('Accueil')
+
+ await gotoPath(page, '/en')
+ expect(await getText(page, '#home-header')).toEqual('Homepage')
+
+ await restore()
+ })
+
+ test('(#2020) pass query parameter', async () => {
+ const { page } = await renderPage('/')
+
+ expect(await getText(page, '#issue-2020-existing')).toBe('/en/test-route?foo=bar')
+ expect(await getText(page, '#issue-2020-nonexistent')).toBe('/i-dont-exist?foo=bar')
+ })
})