Skip to content

Commit 3dfcfb1

Browse files
os-zhuangclaude
andcommitted
docs(i18n): English-only by decision — remove the cn shell
The cn language was declared in docs.site.json and mapped in middleware, but lib/i18n.ts (what fumadocs actually consumes) only ever listed en and there is zero cn content — a config-vs-runtime drift that made the site look bilingual. Remove the declaration and the dead zh->cn Accept-Language mapping; keep the i18n plumbing so a future language is content + one config line. Verified: docs build passes; with Accept-Language: zh-CN, /docs serves the English page with no /cn redirect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 873c099 commit 3dfcfb1

3 files changed

Lines changed: 17 additions & 41 deletions

File tree

apps/docs/lib/i18n.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { defineI18n } from 'fumadocs-core/i18n';
22

33
/**
44
* i18n Configuration for ObjectStack Documentation
5-
*
5+
*
66
* Supported Languages:
77
* - en: English (Default)
8-
* - cn: Chinese (中文)
8+
*
9+
* The docs are English-only by decision (2026-07). To add a language later,
10+
* list it here and provide content — routing already handles the rest.
911
*/
1012
export const i18n = defineI18n({
1113
defaultLanguage: 'en',

apps/docs/middleware.ts

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,6 @@ function setLocaleCookie(response: NextResponse, locale: string): void {
1919
});
2020
}
2121

22-
/**
23-
* Language code mapping
24-
* Maps browser language codes to our supported language codes
25-
*/
26-
const LANGUAGE_MAPPING: Record<string, string> = {
27-
'zh': 'cn', // Chinese -> cn
28-
'zh-CN': 'cn', // Chinese (China) -> cn
29-
'zh-TW': 'cn', // Chinese (Taiwan) -> cn
30-
'zh-HK': 'cn', // Chinese (Hong Kong) -> cn
31-
};
32-
33-
/**
34-
* Normalize language code to match our supported languages
35-
*/
36-
function normalizeLanguage(lang: string): string {
37-
// Check direct mapping first
38-
if (LANGUAGE_MAPPING[lang]) {
39-
return LANGUAGE_MAPPING[lang];
40-
}
41-
42-
// Check if the base language (without region) is mapped
43-
const baseLang = lang.split('-')[0];
44-
if (LANGUAGE_MAPPING[baseLang]) {
45-
return LANGUAGE_MAPPING[baseLang];
46-
}
47-
48-
return lang;
49-
}
50-
5122
/**
5223
* Get the preferred language from the request
5324
*/
@@ -62,12 +33,9 @@ function getPreferredLanguage(request: NextRequest): string {
6233
const negotiatorHeaders = Object.fromEntries(request.headers.entries());
6334
const negotiator = new Negotiator({ headers: negotiatorHeaders });
6435
const browserLanguages = negotiator.languages();
65-
66-
// Normalize browser languages to match our supported languages
67-
const normalizedLanguages = browserLanguages.map(normalizeLanguage);
68-
36+
6937
// Find the first match
70-
for (const lang of normalizedLanguages) {
38+
for (const lang of browserLanguages) {
7139
if (SUPPORTED_LANGUAGES.includes(lang)) {
7240
return lang;
7341
}
@@ -82,9 +50,11 @@ function getPreferredLanguage(request: NextRequest): string {
8250
* This middleware:
8351
* - Detects the user's preferred language from browser settings or cookies
8452
* - Redirects users to the appropriate localized version
85-
* - For default language (en): keeps URL as "/" (with internal rewrite)
86-
* - For other languages (cn): redirects to "/cn/"
53+
* - For the default language (en): keeps URL as "/" (with internal rewrite)
8754
* - Stores language preference as a cookie
55+
*
56+
* The docs are English-only by decision (2026-07); the i18n plumbing stays so a
57+
* future language only needs entries in lib/i18n.ts and content, not new routing.
8858
*/
8959
export default function middleware(request: NextRequest) {
9060
const { pathname } = request.nextUrl;

content/docs.site.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"i18n": {
99
"enabled": true,
1010
"defaultLanguage": "en",
11-
"languages": ["en", "cn"
11+
"languages": [
12+
"en"
1213
]
1314
},
1415
"branding": {
@@ -18,7 +19,7 @@
1819
"dark": "/logo.svg"
1920
},
2021
"theme": {
21-
"accentColor": "blue",
22+
"accentColor": "blue",
2223
"radius": "0.5rem"
2324
}
2425
},
@@ -34,7 +35,10 @@
3435
}
3536
],
3637
"socials": [
37-
{ "platform": "github", "url": "https://github.com/objectstack-ai/spec" }
38+
{
39+
"platform": "github",
40+
"url": "https://github.com/objectstack-ai/spec"
41+
}
3842
]
3943
},
4044
"sidebar": {

0 commit comments

Comments
 (0)