Internationalization
Support multiple languages in your documentation
Before you get started
Fumadocs is not a full-powered i18n library, you can also use other libraries like next-intl. I18n functionality of Fumadocs works without the built-in middleware.
You can setup i18n using Fumadocs CLI or update the configurations manually.
Read the Next.js Docs to learn more about implementing I18n in Next.js.
Auto Setup
Initialize i18n with CLI.
Manual Setup
Define the i18n configurations in a file, we will import it with @/ilb/i18n
in this guide.
Change your current source configurations.
Update the usages to your source to include a locale code:
Note that without providing a locale code, it uses your default locale instead. You can see Source API for other usages.
Middleware
Create a middleware that redirects users to appropriate locale.
See Middleware for customisable options.
Root Layout
Create a dynamic route /app/[lang]
, and move all special files from /app
to
the folder.
A I18nProvider
is needed for localization. Wrap the root provider inside your I18n provider.
Writing Documents
see Page Conventions to learn how to organize your documents.
Search
Configure i18n on your search solution.
You don't need further changes if you're using the createFromSource
shortcut.
For the built-in Orama search, see Search I18n.
Adding Translations
We only provide English translation by default, you have to pass your translations to the provider.
Add Language Switch
To allow users changing their language, enable i18n
on your layouts.
Navigation
Fumadocs will only handle i18n navigation for its own layouts (e.g. sidebar components),
you have to re-create components like <Link>
from next/link
and useParams
hook to auto attend the locale to href
.
In addition, the fumadocs-core/dynamic-link
component supports linking to dynamic hrefs, including the locale prefix.
For Markdown/MDX content, you may use it instead of the default anchor (a
) component:
Last updated on