diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 0633784c85e7..dd87c15fede9 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -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 }) diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index cc5f14a7a5ff..318ff6e920fd 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -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, diff --git a/test/integration/i18n-support/test/index.test.js b/test/integration/i18n-support/test/index.test.js index 90f8f36835e2..565e910b8eff 100644 --- a/test/integration/i18n-support/test/index.test.js +++ b/test/integration/i18n-support/test/index.test.js @@ -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)