Skip to content

Commit

Permalink
Document i18n locale limit (vercel#27542)
Browse files Browse the repository at this point in the history
Add check for i18n locale count and ensure the limit is documented

## Documentation / Examples

- [x] Make sure the linting passes
  • Loading branch information
ijjk authored Jul 27, 2021
1 parent b0f516d commit 5eaca0f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/advanced-features/i18n-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,8 @@ export const getStaticPaths = ({ locales }) => {
}
}
```

## Limits for the i18n config

- `locales`: 100 total locales
- `domains`: 100 total locale domain items
4 changes: 2 additions & 2 deletions errors/invalid-i18n-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 6 additions & 0 deletions packages/next/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 5eaca0f

Please sign in to comment.