From 8bf10dbca566f4832f4327d81107ce3f27b26d4f Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 27 Jul 2021 14:10:20 -0500 Subject: [PATCH 1/2] Document i18n locale limit --- docs/advanced-features/i18n-routing.md | 5 +++++ packages/next/server/config.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/docs/advanced-features/i18n-routing.md b/docs/advanced-features/i18n-routing.md index c21b2b9e73d67..5932f80d77461 100644 --- a/docs/advanced-features/i18n-routing.md +++ b/docs/advanced-features/i18n-routing.md @@ -281,3 +281,8 @@ export const getStaticPaths = ({ locales }) => { } } ``` + +## Limits for the i18n config + +- `locales`: 100 total locales +- `domains`: 100 total locale domain items diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index fae751e863a78..9919ca951703e 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -320,6 +320,12 @@ function assignDefaults(userConfig: { [key: string]: any }) { ) } + if (i18n.locales.length > 100) { + throw new Error( + `Received ${i18n.locales.length} i18n.locales items which exceeds the max of 100, please reduce the number of items to continue.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config` + ) + } + const defaultLocaleType = typeof i18n.defaultLocale if (!i18n.defaultLocale || defaultLocaleType !== 'string') { From f8d6ace93dede703151b5d9cc0e0f125d6c0a796 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 27 Jul 2021 14:17:45 -0500 Subject: [PATCH 2/2] mention limit in error doc --- errors/invalid-i18n-config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/errors/invalid-i18n-config.md b/errors/invalid-i18n-config.md index 1a1be32af8839..b840d14a61f98 100644 --- a/errors/invalid-i18n-config.md +++ b/errors/invalid-i18n-config.md @@ -2,11 +2,11 @@ #### Why This Error -In your `next.config.js` file you provided an invalid config for the `i18n` field. +In your `next.config.js` file you provided an invalid config for the `i18n` field. This could mean the limit for 100 locale items was exceeded. #### Possible Ways to Fix It -Make sure your `i18n` field follows the allowed config shape and values: +Make sure your `i18n` field follows the allowed config shape, limits, and values: ```js module.exports = {