Internationalization
Support multiple languages in your documentation
Next Docs has built-in support for internationalized routing in Contentlayer. You can define a list of supported languages and pass it to i18n utilities. Read the Next.js Docs to learn more about implementing I18n in Next.js.
Setup
- Put all supported languages in a file.
- Change your current configurations.
- Create i18n middleware.
- Create a dynamic route, ensure all special files are nested under
/app/[lang]
.
Get Pages
To get the pages with specific languages, use the utilities exported from
source.ts
.
Docs Search
You will need some extra configurations in order to implement international document searching.
The default createSearchAPI
doesn't provide functionality for i18n. Instead,
you can use createI18nSearchAPI
.
- Update the route handler.
- Add
locale
to search dialog, this will only allow pages with specified locale to being searched by the user.
Last updated on