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.
feat: set locale domains via runtimeConfig (nuxt-modules#2443)
- Loading branch information
Showing
6 changed files
with
88 additions
and
7 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
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,60 @@ | ||
import { test, expect } from 'vitest' | ||
import { fileURLToPath } from 'node:url' | ||
import { setup, $fetch } from './utils' | ||
import { getDom } from './helper' | ||
|
||
await setup({ | ||
rootDir: fileURLToPath(new URL(`./fixtures/domain`, import.meta.url)), | ||
// overrides | ||
nuxtConfig: { | ||
runtimeConfig: { | ||
public: { | ||
i18n: { | ||
locales: { | ||
en: { | ||
domain: 'en.staging.nuxt-app.localhost' | ||
}, | ||
fr: { | ||
domain: 'fr.staging.nuxt-app.localhost' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
i18n: { | ||
locales: [ | ||
{ | ||
code: 'en', | ||
iso: 'en', | ||
name: 'English', | ||
domain: 'en.nuxt-app.localhost' | ||
}, | ||
{ | ||
code: 'fr', | ||
iso: 'fr-FR', | ||
name: 'Français', | ||
domain: 'fr.nuxt-app.localhost' | ||
} | ||
], | ||
differentDomains: true, | ||
detectBrowserLanguage: { | ||
useCookie: true | ||
} | ||
} | ||
} | ||
}) | ||
|
||
test('pass `<NuxtLink> to props using domains from runtimeConfig', async () => { | ||
const html = await $fetch('/', { | ||
headers: { | ||
Host: 'fr.nuxt-app.localhost' | ||
} | ||
}) | ||
const dom = getDom(html) | ||
expect(dom.querySelector('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( | ||
`http://en.staging.nuxt-app.localhost` | ||
) | ||
expect(dom.querySelector('#switch-locale-path-usages .switch-to-fr a').getAttribute('href')).toEqual( | ||
`http://fr.staging.nuxt-app.localhost` | ||
) | ||
}) |
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
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