Skip to content

Commit 2bce73e

Browse files
authored
docs(i18n): locale fallback
1 parent c6882f8 commit 2bce73e

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

docs/content/en/2.concepts/6.internationalization.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ description: Create multi-language documentation with Docus v4 built-in i18n sup
44
navigation:
55
icon: i-lucide-globe
66
seo:
7-
description: Learn how to set up and manage multi-language documentation with Docus v4 built-in i18n support.
7+
description: Learn how to set up and manage multi-language documentation with
8+
Docus v4 built-in i18n support.
89
---
910

1011
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.
@@ -32,6 +33,7 @@ export default defineNuxtConfig({
3233
}
3334
})
3435
```
36+
3537
::warning
3638
Docus overrides the `@nuxtjs/i18n` strategy to `prefix`.
3739
::
@@ -48,7 +50,7 @@ npx create-docus my-docs -t i18n
4850

4951
When i18n is enabled, organize your content by locale in the `content/` directory:
5052

51-
```
53+
```text
5254
content/
5355
├── en/ # English content
5456
│ ├── index.md # English homepage
@@ -66,7 +68,41 @@ content/
6668
│ └── advanced.md
6769
```
6870

69-
7071
::warning
7172
Each locale should mirror the same directory structure to maintain consistent navigation across languages.
7273
::
74+
75+
## Locale fallback
76+
77+
Docus warns and skips any locale that does not exist in your `content/` directory. Missing locales are not registered.
78+
79+
::prose-tip
80+
This is especially helpful when you extend Docus and use `@nuxtjs/i18n` for the rest of your site, but only want the docs in a subset of languages.
81+
::
82+
83+
Docus detects locales from your nuxt config:
84+
85+
```ts [nuxt.config.ts]
86+
export default defineNuxtConfig({
87+
modules: ['@nuxtjs/i18n'],
88+
i18n: {
89+
locales: ['en', 'fr', 'ja'],
90+
defaultLocale: 'en'
91+
}
92+
})
93+
```
94+
95+
But only register it based on your `content/` folder structure:
96+
97+
```text
98+
content/
99+
├─ en/ # registered ✅
100+
├─ fr/ # registered ✅ (if present)
101+
└─ ja/ # skipped 🚫 (if missing)
102+
```
103+
104+
If a user requests a missing docs locale, Docus redirects to the **default locale**.
105+
106+
::prose-warning
107+
You must set a `defaultLocale` in your i18n config and ensure it exists under `content/<defaultLocale>`
108+
::

0 commit comments

Comments
 (0)