Configuration
Define your i18n configuration:lib/i18n.ts
Configuration Options
File Structure
Fumadocs supports different file organization patterns for i18n content.Dot Notation (parser: 'dot')
Use dots in filenames to indicate locale:
Directory Structure (parser: 'dir')
Organize content in locale directories:
No Parser (parser: 'none')
Manually specify locale for each file:
URL Structure
Default Behavior (hideLocale: 'never')
All locales shown in URL:
Hide Default Locale (hideLocale: 'default-locale')
Default language URL has no prefix:
Always Hide (hideLocale: 'always')
No locale prefix in URLs (uses NextResponse.rewrite):
Source Integration
Integrate i18n with your content source:lib/source.ts
Get Localized Content
Middleware
Handle locale detection and routing:middleware.ts
- Detects locale from URL
- Redirects to appropriate locale
- Handles
hideLocaleconfiguration - Sets locale cookies
Language Switcher
Create a language switcher component:components/language-switcher.tsx
Fallback Language
Configure fallback behavior for missing translations:fallbackLanguage: null, pages without translations will return 404.
Page Tree Navigation
The page tree respects locale:app/[lang]/docs/layout.tsx
Search with I18n
Create localized search indexes:app/api/search/route.ts
Translated UI Text
Provide translations for UI elements:app/[lang]/layout.tsx
Dynamic Routes
Set up dynamic routing for localized pages:app/[lang]/docs/[[...slug]]/page.tsx
Breadcrumbs with I18n
Breadcrumbs work automatically with i18n:Best Practices
- Use defineI18n: Always use the helper for type safety
- Consistent Structure: Keep the same file structure across all locales
- Default Language: Always provide content in your default language
- URL Strategy: Choose
hideLocalebased on your SEO strategy - Search Indexes: Create separate search indexes per locale for better results
- Fallback Content: Use
fallbackLanguageto show English content when translations are missing - Dynamic Routes: Generate static params for all locale/slug combinations