Internationalization
Docus v4 introduces native internationalization support based on the @nuxtjs/i18n
module, allowing you to create documentation in multiple languages with automatic routing and content management.
Features
- Built-in i18n module: Native integration with
@nuxtjs/i18n
- Dynamic locale routing: Automatic URL prefixing with language codes (
/en/docs
,/fr/docs
) - Content collections per locale: Separate content management for each language
- Language switcher: Built-in component for switching between locales
Setup an existing project
To enable i18n in your Docus project, add the @nuxtjs/i18n
module to your nuxt.config.ts
and define your locales:
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
defaultLocale: 'en',
locales: [
{ code: 'en', name: 'English' },
{ code: 'fr', name: 'Français' },
],
}
})
@nuxtjs/i18n
strategy to prefix
.Create a new project with i18n template
When creating a new project, you can choose the i18n template for pre-configured internationalization:
npx create-docus my-docs -t i18n
Directory Structure
When i18n is enabled, organize your content by locale in the content/
directory:
content/
├── en/ # English content
│ ├── index.md # English homepage
│ ├── getting-started/
│ │ ├── installation.md
│ │ └── configuration.md
│ └── guide/
│ └── advanced.md
├── fr/ # French content
│ ├── index.md # French homepage
│ ├── getting-started/
│ │ ├── installation.md
│ │ └── configuration.md
│ └── guide/
│ └── advanced.md
Locale fallback
Docus warns and skips any locale that does not exist in your content/
directory. Missing locales are not registered.
@nuxtjs/i18n
for the rest of your site, but only want the docs in a subset of languages.Docus detects locales from your nuxt config:
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
locales: ['en', 'fr', 'ja'],
defaultLocale: 'en'
}
})
But only register it based on your content/
folder structure:
content/
├─ en/ # registered ✅
├─ fr/ # registered ✅ (if present)
└─ ja/ # skipped 🚫 (if missing)
If a user requests a missing docs locale, Docus redirects to the default locale.
defaultLocale
in your i18n config and ensure it exists under content/<defaultLocale>