Unverified Commit 9a13dd34 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Enable i18n feature flag (#18303)

parent 0f250514
......@@ -98,9 +98,7 @@ export function createEntrypoints(
loadedEnvFiles: Buffer.from(JSON.stringify(loadedEnvFiles)).toString(
'base64'
),
i18n: config.experimental.i18n
? JSON.stringify(config.experimental.i18n)
: '',
i18n: config.i18n ? JSON.stringify(config.i18n) : '',
}
Object.keys(pages).forEach((page) => {
......
......@@ -336,7 +336,7 @@ export default async function build(
}
}),
dataRoutes: [],
i18n: config.experimental.i18n || undefined,
i18n: config.i18n || undefined,
}
await promises.mkdir(distDir, { recursive: true })
......@@ -576,8 +576,8 @@ export default async function build(
page,
serverBundle,
runtimeEnvConfig,
config.experimental.i18n?.locales,
config.experimental.i18n?.defaultLocale
config.i18n?.locales,
config.i18n?.defaultLocale
)
if (workerResult.isHybridAmp) {
......@@ -739,7 +739,7 @@ export default async function build(
// n.b. we cannot handle this above in combinedPages because the dynamic
// page must be in the `pages` array, but not in the mapping.
exportPathMap: (defaultMap: any) => {
const { i18n } = config.experimental
const { i18n } = config
// Dynamically routed pages should be prerendered to be used as
// a client-side skeleton (fallback) while data is being fetched.
......@@ -878,7 +878,7 @@ export default async function build(
pagesManifest[page] = relativeDest
}
const { i18n } = config.experimental
const { i18n } = config
const isNotFound = ssgNotFoundPaths.includes(page)
// for SSG files with i18n the non-prerendered variants are
......@@ -960,7 +960,7 @@ export default async function build(
}
if (isSsg) {
const { i18n } = config.experimental
const { i18n } = config
// For a non-dynamic SSG page, we must copy its data file from export.
if (!isDynamic) {
......
......@@ -1004,12 +1004,8 @@ export default async function getBaseWebpackConfig(
}),
'process.env.__NEXT_ROUTER_BASEPATH': JSON.stringify(config.basePath),
'process.env.__NEXT_HAS_REWRITES': JSON.stringify(hasRewrites),
'process.env.__NEXT_I18N_SUPPORT': JSON.stringify(
!!config.experimental.i18n
),
'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(
config.experimental.i18n.domains
),
'process.env.__NEXT_I18N_SUPPORT': JSON.stringify(!!config.i18n),
'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n.domains),
'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId),
...(isServer
? {
......
......@@ -283,7 +283,7 @@ export default async function exportApp(
}
}
const { i18n } = nextConfig.experimental
const { i18n } = nextConfig
if (i18n && !options.buildExport) {
throw new Error(
......
......@@ -45,6 +45,7 @@ const defaultConfig: { [key: string]: any } = {
basePath: '',
sassOptions: {},
trailingSlash: false,
i18n: false,
experimental: {
cpus: Math.max(
1,
......@@ -62,7 +63,6 @@ const defaultConfig: { [key: string]: any } = {
optimizeFonts: false,
optimizeImages: false,
scrollRestoration: false,
i18n: false,
},
future: {
excludeDefaultMomentLocales: false,
......@@ -310,8 +310,8 @@ function assignDefaults(userConfig: { [key: string]: any }) {
}
}
if (result.experimental?.i18n) {
const { i18n } = result.experimental
if (result.i18n) {
const { i18n } = result
const i18nType = typeof i18n
if (i18nType !== 'object') {
......
......@@ -198,7 +198,7 @@ export default class Server {
? requireFontManifest(this.distDir, this._isLikeServerless)
: null,
optimizeImages: this.nextConfig.experimental.optimizeImages,
defaultLocale: this.nextConfig.experimental.i18n?.defaultLocale,
defaultLocale: this.nextConfig.i18n?.defaultLocale,
}
// Only the `publicRuntimeConfig` key is exposed to the client side
......@@ -298,8 +298,7 @@ export default class Server {
parsedUrl.query = parseQs(parsedUrl.query)
}
const { basePath } = this.nextConfig
const { i18n } = this.nextConfig.experimental
const { basePath, i18n } = this.nextConfig
if (basePath && req.url?.startsWith(basePath)) {
// store original URL to allow checking if basePath was
......@@ -577,7 +576,7 @@ export default class Server {
// re-create page's pathname
let pathname = `/${params.path.join('/')}`
const { i18n } = this.nextConfig.experimental
const { i18n } = this.nextConfig
if (i18n) {
const { host } = req?.headers || {}
......@@ -1213,7 +1212,7 @@ export default class Server {
const locale = query.__nextLocale as string
delete query.__nextLocale
const { i18n } = this.nextConfig.experimental
const { i18n } = this.nextConfig
const locales = i18n.locales as string[]
let previewData: string | false | object | undefined
......@@ -1243,7 +1242,7 @@ export default class Server {
)
}
if (this.nextConfig.experimental.i18n) {
if (this.nextConfig.i18n) {
return normalizeLocalePath(path, locales).pathname
}
return path
......
......@@ -534,7 +534,7 @@ export default class DevServer extends Server {
const __getStaticPaths = async () => {
const { publicRuntimeConfig, serverRuntimeConfig } = this.nextConfig
const { locales, defaultLocale } = this.nextConfig.experimental.i18n || {}
const { locales, defaultLocale } = this.nextConfig.i18n || {}
const paths = await this.staticPathsWorker.loadStaticPaths(
this.distDir,
......
......@@ -114,8 +114,7 @@ export function eventCliSession(
const userConfiguration = getNextConfig(phase, dir)
const { images, experimental } = userConfiguration || {}
const { i18n } = experimental || {}
const { images, i18n } = userConfiguration || {}
const payload: EventCliSessionStarted = {
nextVersion: process.env.__NEXT_VERSION,
......
module.exports = {
// target: 'experimental-serverless-trace',
experimental: {
i18n: {
locales: ['nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en-US', 'en'],
defaultLocale: 'en-US',
domains: [
{
// used for testing, this should not be needed in most cases
// as production domains should always use https
http: true,
domain: 'example.be',
defaultLocale: 'nl-BE',
locales: ['nl', 'nl-NL', 'nl-BE'],
},
{
http: true,
domain: 'example.fr',
defaultLocale: 'fr',
locales: ['fr-BE'],
},
],
},
i18n: {
locales: ['nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en-US', 'en'],
defaultLocale: 'en-US',
domains: [
{
// used for testing, this should not be needed in most cases
// as production domains should always use https
http: true,
domain: 'example.be',
defaultLocale: 'nl-BE',
locales: ['nl', 'nl-NL', 'nl-BE'],
},
{
http: true,
domain: 'example.fr',
defaultLocale: 'fr',
locales: ['fr-BE'],
},
],
},
}
......@@ -4,21 +4,19 @@ module.exports = phase => {
sizes: [64, 128, 256, 512, 1024],
domains: ['example.com'],
},
experimental: {
i18n: {
locales: ['en','nl','fr'],
defaultLocale: 'en',
domains: [
{
domain: 'example.com',
defaultLocale: 'en'
},
{
domain: 'example.fr',
defaultLocale: 'fr'
}
]
}
i18n: {
locales: ['en','nl','fr'],
defaultLocale: 'en',
domains: [
{
domain: 'example.com',
defaultLocale: 'en'
},
{
domain: 'example.fr',
defaultLocale: 'fr'
}
]
}
}
}
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