Read the Next.js Docs to learn more about implementing I18n in Next.js.
Define all supported languages in a file.
Change your current source configurations.
Create the middleware that redirects users when missing locale.
Create a dynamic route /app/[lang]
, and move all special files to
the folder.
see Page Conventions to learn how to organize your documents.
Configure i18n on your search solution. For Flexsearch, see Setup I18n.
To get the pages of a specific language, use the utilities exported from
source.ts
.
Generate parameters for every language and page.
You can also customise the I18n middleware.
To hide the locale prefix, for example, use /
instead of /en
where en
is the default locale, use the hidePrefix
option.
Mode | Description |
---|
always | Always hide the prefix |
default-locale | Only hide the default locale |
never | Never hide the prefix (default) |
It uses NextResponse.rewrite
under the hood.