-
-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support variable default export for defineI18nConfig (#2792)
* fix: support variable default export for `defineI18nConfig` * test: add variable export `defineI18nConfig` test
- Loading branch information
1 parent
cba5c3a
commit cf8cd25
Showing
7 changed files
with
126 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div> | ||
<NuxtPage /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const config = defineI18nConfig(() => { | ||
return { | ||
legacy: false, | ||
locale: 'ja', | ||
messages: { | ||
ja: { | ||
big: 'こんにちは,'.repeat(10) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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' | ||
} | ||
] | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import { useI18n } from 'vue-i18n' | ||
const { t } = useI18n() | ||
</script> | ||
|
||
<template> | ||
<p id="render">{{ t('big') }}</p> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters