Skip to content

Commit acd44c5

Browse files
authored
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: #17370
1 parent b14331c commit acd44c5

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

packages/next/build/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,15 @@ export default async function build(
306306
dataRouteRegex: string
307307
namedDataRouteRegex?: string
308308
}>
309+
i18n?: {
310+
locales: string[]
311+
defaultLocale: string[]
312+
domains: Array<{
313+
domain: string
314+
defaultLocale: string
315+
locales: string[]
316+
}>
317+
}
309318
} = {
310319
version: 3,
311320
pages404: true,
@@ -325,6 +334,7 @@ export default async function build(
325334
}
326335
}),
327336
dataRoutes: [],
337+
i18n: config.experimental.i18n || undefined,
328338
}
329339

330340
await promises.mkdir(distDir, { recursive: true })

packages/next/export/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ export default async function exportApp(
285285

286286
const { i18n } = nextConfig.experimental
287287

288+
if (i18n && !options.buildExport) {
289+
throw new Error(
290+
`i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment`
291+
)
292+
}
293+
288294
// Start the rendering process
289295
const renderOpts = {
290296
dir,

test/integration/i18n-support/test/index.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ async function addDefaultLocaleCookie(browser) {
3434
}
3535

3636
function runTests(isDev) {
37+
if (!isDev) {
38+
it('should add i18n config to routes-manifest', async () => {
39+
const routesManifest = await fs.readJSON(
40+
join(appDir, '.next/routes-manifest.json')
41+
)
42+
43+
expect(routesManifest.i18n).toEqual({
44+
locales: ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en'],
45+
defaultLocale: 'en-US',
46+
domains: [
47+
{
48+
http: true,
49+
domain: 'example.be',
50+
defaultLocale: 'nl-BE',
51+
},
52+
{
53+
http: true,
54+
domain: 'example.fr',
55+
defaultLocale: 'fr',
56+
},
57+
],
58+
})
59+
})
60+
}
61+
3762
it('should navigate with locale prop correctly', async () => {
3863
const browser = await webdriver(appPort, '/links?nextLocale=fr')
3964
await addDefaultLocaleCookie(browser)

0 commit comments

Comments
 (0)