Unverified Commit 5eaca0ff authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Document i18n locale limit (#27542)

Add check for i18n locale count and ensure the limit is documented

## Documentation / Examples

- [x] Make sure the linting passes
parent b0f516db
...@@ -281,3 +281,8 @@ export const getStaticPaths = ({ locales }) => { ...@@ -281,3 +281,8 @@ export const getStaticPaths = ({ locales }) => {
} }
} }
``` ```
## Limits for the i18n config
- `locales`: 100 total locales
- `domains`: 100 total locale domain items
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
#### Why This Error #### 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 #### 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 ```js
module.exports = { module.exports = {
......
...@@ -320,6 +320,12 @@ function assignDefaults(userConfig: { [key: string]: any }) { ...@@ -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 const defaultLocaleType = typeof i18n.defaultLocale
if (!i18n.defaultLocale || defaultLocaleType !== 'string') { if (!i18n.defaultLocale || defaultLocaleType !== 'string') {
......
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