-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cannot navigate on toppage (#2240)
- Loading branch information
Showing
11 changed files
with
146 additions
and
17 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,30 @@ | ||
<script lang="ts" setup> | ||
const localePath = useLocalePath() | ||
</script> | ||
<template> | ||
<div> | ||
<button | ||
v-for="locale in $i18n.locales" | ||
:id="locale.code" | ||
:key="locale.code" | ||
@click="$i18n.setLocale(locale.code)" | ||
> | ||
{{ locale.name }} | ||
</button> | ||
</div> | ||
|
||
<nuxt-page /> | ||
|
||
<p> | ||
Test: | ||
<nuxt-link id="disabled-route" :to="localePath('/disabled-localized-route')"> | ||
Page with disabled localized route | ||
</nuxt-link> | ||
</p> | ||
</template> | ||
|
||
<style lang="css" scoped> | ||
button { | ||
margin-right: 16px; | ||
} | ||
</style> |
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,3 @@ | ||
{ | ||
"hello": "Hello!" | ||
} |
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,3 @@ | ||
{ | ||
"hello": "Bonjour!" | ||
} |
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,3 @@ | ||
{ | ||
"hello": "Witaj!" | ||
} |
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,33 @@ | ||
// https://v3.nuxtjs.org/api/configuration/nuxt.config | ||
export default defineNuxtConfig({ | ||
modules: ['@nuxtjs/i18n'], | ||
i18n: { | ||
locales: [ | ||
{ | ||
code: 'en', | ||
flag: 'us', | ||
iso: 'en-US', | ||
file: 'en.json', | ||
name: 'English' | ||
}, | ||
{ code: 'pl', flag: 'pl', iso: 'pl-PL', file: 'pl.json', name: 'Polski' }, | ||
{ | ||
code: 'fr', | ||
flag: 'fr', | ||
iso: 'fr-FR', | ||
file: 'fr.json', | ||
name: 'Français' | ||
} | ||
], | ||
defaultLocale: 'en', | ||
strategy: 'prefix', | ||
langDir: 'locales', | ||
detectBrowserLanguage: { | ||
useCookie: true, | ||
// cookieKey: 'locale', | ||
// fallbackLocale: 'en', | ||
alwaysRedirect: false, | ||
redirectOn: 'root' | ||
} | ||
} | ||
}) |
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,14 @@ | ||
{ | ||
"name": "nuxt3-test-issues-1889", | ||
"private": true, | ||
"scripts": { | ||
"build": "nuxt build", | ||
"dev": "nuxt dev", | ||
"generate": "nuxt generate", | ||
"preview": "nuxt preview" | ||
}, | ||
"devDependencies": { | ||
"@nuxtjs/i18n": "latest", | ||
"nuxt": "latest" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
specs/fixtures/issues/1889/pages/disabled-localized-route.vue
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,10 @@ | ||
<template> | ||
<div> | ||
<h1 id="disable-route-text">Page with disabled localized route</h1> | ||
<nuxt-link id="goto-home" :to="localePath('/')"> Goto Home </nuxt-link> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
defineI18nRoute(false) | ||
</script> |
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,3 @@ | ||
<template> | ||
<h1 id="hello-text">{{ $t('hello') }}</h1> | ||
</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,28 @@ | ||
import { test, expect, describe } from 'vitest' | ||
import { fileURLToPath } from 'node:url' | ||
import { setup, createPage, url } from '../utils' | ||
import { getText } from '../helper' | ||
|
||
describe('#1889', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL(`../fixtures/issues/1889`, import.meta.url)) | ||
}) | ||
|
||
test('navigate work on `defineI18nRoute(false)`', async () => { | ||
const home = url('/') | ||
const page = await createPage() | ||
await page.goto(home) | ||
|
||
// switch 'pl' locale | ||
await page.locator('#pl').click() | ||
expect(await getText(page, '#hello-text')).toEqual('Witaj!') | ||
|
||
// navigate to disabled route | ||
await page.locator('#disabled-route').click() | ||
expect(await getText(page, '#disable-route-text')).toEqual('Page with disabled localized route') | ||
|
||
// back to home | ||
await page.locator('#goto-home').click() | ||
expect(await getText(page, '#hello-text')).toEqual('Witaj!') | ||
}) | ||
}) |
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
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