forked from nuxt-modules/i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
prefix_and_default
strategy routing (nuxt-modules#2249)
- Loading branch information
Showing
15 changed files
with
156 additions
and
11 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
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,25 @@ | ||
<template> | ||
<div> | ||
<NuxtLayout> | ||
<nuxt-link id="root" class="link" to="/"> / </nuxt-link> | ||
<nuxt-link id="root-en" class="link" to="/en"> /en </nuxt-link> | ||
|
||
<nuxt-link id="about-en" class="link" to="/en/about"> /en/about </nuxt-link> | ||
<nuxt-link id="about" class="link" to="/about"> /about </nuxt-link> | ||
<nuxt-link id="about-ar" class="link" to="/ar/about"> /ar/about </nuxt-link> | ||
<nuxt-link id="example-ar" class="link" to="/ar/example"> /ar/example </nuxt-link> | ||
|
||
<br /> | ||
<br /> | ||
|
||
<code id="route-path">{{ useRoute().path }}</code> | ||
<NuxtPage /> | ||
</NuxtLayout> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.link { | ||
padding: 15px; | ||
} | ||
</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 @@ | ||
export default { | ||
title: 'مرحبا.. هذه اللغة العربية', | ||
}; |
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 @@ | ||
export default { | ||
title: 'Hello this is English', | ||
}; |
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,4 @@ | ||
import ar from './ar-ar'; | ||
import en from './en-en'; | ||
|
||
export default { ar, en }; |
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> | ||
<slot /> | ||
</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,31 @@ | ||
// https://v3.nuxtjs.org/api/configuration/nuxt.config | ||
export default defineNuxtConfig({ | ||
modules: ['@nuxtjs/i18n'], | ||
i18n: { | ||
baseUrl: 'https://abwaab.com', | ||
locales: [ | ||
{ | ||
code: 'en', | ||
country: '', | ||
iso: 'en', | ||
lang: 'en', | ||
file: 'en-en.js', | ||
dir: 'ltr' | ||
}, | ||
{ | ||
code: 'ar', | ||
country: '', | ||
iso: 'ar', | ||
lang: 'ar', | ||
file: 'ar-ar.js', | ||
dir: 'rtl' | ||
} | ||
], | ||
|
||
strategy: 'prefix_and_default', | ||
detectBrowserLanguage: false, | ||
defaultLocale: 'ar', | ||
lazy: true, | ||
langDir: 'i18n/' | ||
} | ||
}) |
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-2247", | ||
"private": true, | ||
"scripts": { | ||
"build": "nuxt build", | ||
"dev": "nuxt dev", | ||
"generate": "nuxt generate", | ||
"preview": "nuxt preview" | ||
}, | ||
"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,5 @@ | ||
<template> | ||
<div> | ||
{{ $t('title') }} | ||
</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,5 @@ | ||
<template> | ||
<div> | ||
{{ $t('title') }} | ||
</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,3 @@ | ||
<template> | ||
<div>Home Page</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
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,46 @@ | ||
import { test, expect, describe } from 'vitest' | ||
import { fileURLToPath } from 'node:url' | ||
import { setup, createPage, url } from '../utils' | ||
import { getText } from '../helper' | ||
|
||
describe('#2247', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL(`../fixtures/issues/2247`, import.meta.url)) | ||
}) | ||
|
||
test('navigate on `prefix_and_default`', async () => { | ||
const home = url('/') | ||
const page = await createPage() | ||
await page.goto(home) | ||
|
||
await page.locator('#root-en').click() | ||
expect(await getText(page, '#route-path')).include('/en') | ||
|
||
await page.locator('#root').click() | ||
expect(await getText(page, '#route-path')).include('/') | ||
|
||
await page.locator('#about-en').click() | ||
expect(await getText(page, '#route-path')).include('/en/about') | ||
|
||
await page.locator('#root').click() | ||
expect(await getText(page, '#route-path')).include('/') | ||
|
||
await page.locator('#about').click() | ||
expect(await getText(page, '#route-path')).include('/about') | ||
|
||
await page.locator('#about-ar').click() | ||
expect(await getText(page, '#route-path')).include('/ar/about') | ||
|
||
await page.locator('#root').click() | ||
expect(await getText(page, '#route-path')).include('/') | ||
|
||
await page.locator('#example-ar').click() | ||
expect(await getText(page, '#route-path')).include('/ar/example') | ||
|
||
await page.locator('#about-ar').click() | ||
expect(await getText(page, '#route-path')).include('/ar/about') | ||
|
||
await page.locator('#root').click() | ||
expect(await getText(page, '#route-path')).include('/') | ||
}) | ||
}) |
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