Skip to content

Commit 1efbf5c

Browse files
committed
feat: use translation in sidebar tabs
1 parent 92d159d commit 1efbf5c

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

apps/docs/messages/en.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
"title": "Next.js",
44
"doc": "Documentation"
55
},
6+
"sidebar": {
7+
"app": {
8+
"title": "Using App Router",
9+
"description": "Features available in /app"
10+
},
11+
"pages": {
12+
"title": "Using Pages Router",
13+
"description": "Features available in /pages"
14+
},
15+
"version": {
16+
"latest": {
17+
"title": "Using Latest Version"
18+
},
19+
"v14": {
20+
"title": "Using Version 14"
21+
},
22+
"v13": {
23+
"title": "Using Version 13"
24+
}
25+
}
26+
},
627
"HomePage": {
728
"title": "Hello world!",
829
"intro": "You can open <Link>/docs</Link> and see the documentation."

apps/docs/messages/zh-hans.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
"title": "Next.js 简体中文",
44
"doc": "文档"
55
},
6+
"sidebar": {
7+
"app": {
8+
"title": "使用 App 路由器",
9+
"description": "/app 中可用的功能"
10+
},
11+
"pages": {
12+
"title": "使用 Pages 路由器",
13+
"description": "/pages 中可用的功能"
14+
},
15+
"version": {
16+
"latest": {
17+
"title": "使用最新版本"
18+
},
19+
"v14": {
20+
"title": "使用 14 版本"
21+
},
22+
"v13": {
23+
"title": "使用 13 版本"
24+
}
25+
}
26+
},
627
"HomePage": {
728
"title": "你好,世界!",
829
"intro": "你可以打开 <Link>/docs</Link> 来查看文档。"

apps/docs/src/components/layout.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
type DocsLayoutProps,
1616
DocsLayout as FumaDocsLayout,
1717
} from 'fumadocs-ui/layouts/notebook';
18+
import { useTranslations } from 'next-intl';
1819
import type { ReactNode } from 'react';
1920

2021
export function DocsLayout({
@@ -29,19 +30,20 @@ export function DocsLayout({
2930
routerType: RouterType;
3031
}) {
3132
const baseOptions = useBaseOptions();
33+
const t = useTranslations('sidebar');
3234
const { appDocsRoot, pagesDocsRoot, docsRoot, docUrl, isPages } =
3335
parseDocId(docId);
3436
const options = [
3537
{
36-
title: 'Using App Router',
37-
description: 'Features available in /app',
38+
title: t('app.title'),
39+
description: t('app.description'),
3840
icon: <NextAppIcon />,
3941
url: appDocsRoot,
4042
...(routerType !== 'pages' ? { urls: new Set([docUrl]) } : {}),
4143
},
4244
{
43-
title: 'Using Pages Router',
44-
description: 'Features available in /pages',
45+
title: t('pages.title'),
46+
description: t('pages.description'),
4547
icon: <NextPagesIcon />,
4648
url: pagesDocsRoot,
4749
...(routerType === 'pages' ? { urls: new Set([docUrl]) } : {}),
@@ -59,19 +61,19 @@ export function DocsLayout({
5961
<RootToggle
6062
options={[
6163
{
62-
title: 'Using Latest Version',
64+
title: t('version.latest.title'),
6365
description: '15.3.2',
6466
icon: <NextLastedVersionIcon />,
6567
url: '/docs/',
6668
},
6769
{
68-
title: 'Using Version 14',
70+
title: t('version.v14.title'),
6971
description: '14.2.29',
7072
icon: <NextOldVersionIcon />,
7173
url: '/docs/14',
7274
},
7375
{
74-
title: 'Using Version 13',
76+
title: t('version.v13.title'),
7577
description: '13.5.11',
7678
icon: <NextOldVersionIcon />,
7779
url: '/docs/13',

0 commit comments

Comments
 (0)