Unverified Commit acd44c5b authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add i18n items to routes manifest (#17893)

This adds the i18n config items to the routes-manifest so that they can accessed in the builder. This doesn't increment the routes-manifest version as existing value shapes haven't been modified and an additional non-breaking value is being added

x-ref: https://github.com/vercel/next.js/pull/17370
parent b14331c5
......@@ -306,6 +306,15 @@ export default async function build(
dataRouteRegex: string
namedDataRouteRegex?: string
}>
i18n?: {
locales: string[]
defaultLocale: string[]
domains: Array<{
domain: string
defaultLocale: string
locales: string[]
}>
}
} = {
version: 3,
pages404: true,
......@@ -325,6 +334,7 @@ export default async function build(
}
}),
dataRoutes: [],
i18n: config.experimental.i18n || undefined,
}
await promises.mkdir(distDir, { recursive: true })
......
......@@ -285,6 +285,12 @@ export default async function exportApp(
const { i18n } = nextConfig.experimental
if (i18n && !options.buildExport) {
throw new Error(
`i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment`
)
}
// Start the rendering process
const renderOpts = {
dir,
......
......@@ -34,6 +34,31 @@ async function addDefaultLocaleCookie(browser) {
}
function runTests(isDev) {
if (!isDev) {
it('should add i18n config to routes-manifest', async () => {
const routesManifest = await fs.readJSON(
join(appDir, '.next/routes-manifest.json')
)
expect(routesManifest.i18n).toEqual({
locales: ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en'],
defaultLocale: 'en-US',
domains: [
{
http: true,
domain: 'example.be',
defaultLocale: 'nl-BE',
},
{
http: true,
domain: 'example.fr',
defaultLocale: 'fr',
},
],
})
})
}
it('should navigate with locale prop correctly', async () => {
const browser = await webdriver(appPort, '/links?nextLocale=fr')
await addDefaultLocaleCookie(browser)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment