Skip to content

Commit e17eb95

Browse files
authored
Merge pull request #4347 from udecode/i18n-2
New Chinese docs
2 parents 4a61192 + 93fed36 commit e17eb95

File tree

138 files changed

+15764
-6207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+15764
-6207
lines changed

apps/www/src/components/docs-nav.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { cn } from '@/lib/utils';
2222
import { hrefWithLocale } from '@/lib/withLocale';
2323

2424
export function DocsNav({ config }: { config: DocsConfig }) {
25+
const locale = useLocale();
2526
const pathname = usePathname();
2627
const [filter, setFilter] = useState('');
2728
const [activeSection, setActiveSection] = useState<string | undefined>();
@@ -205,7 +206,7 @@ export function DocsNav({ config }: { config: DocsConfig }) {
205206
>
206207
<AccordionTrigger className="h-9 shrink-0 items-center px-2 py-1 text-sm outline-none">
207208
<div className="flex items-center">
208-
{item.title}
209+
{locale === 'cn' ? item.titleCn || item.title : item.title}
209210
{item.label && (
210211
<div className="flex gap-1">
211212
{castArray(item.label).map((label, labelIndex) => (
@@ -276,7 +277,7 @@ function DocsNavItems({
276277
item.disabled && 'cursor-not-allowed opacity-60'
277278
)}
278279
>
279-
{item.title}
280+
{locale === 'cn' ? item.titleCn || item.title : item.title}
280281
{item.label && (
281282
<span className="ml-2 rounded-md bg-muted px-1.5 py-0.5 text-xs leading-none text-muted-foreground no-underline group-hover:no-underline">
282283
{item.label}
@@ -299,7 +300,7 @@ function DocsNavItems({
299300
rel={item.external ? 'noreferrer' : ''}
300301
target={item.external ? '_blank' : ''}
301302
>
302-
{item.title}
303+
{locale === 'cn' ? item.titleCn || item.title : item.title}
303304
{item.label && (
304305
<div className="ml-2 flex gap-1">
305306
{castArray(item.label).map((label, labelIndex) => (
@@ -327,7 +328,7 @@ function DocsNavItems({
327328
'flex h-8 w-full items-center truncate rounded-lg px-2 font-medium text-foreground select-none'
328329
)}
329330
>
330-
{item.title}
331+
{locale === 'cn' ? item.titleCn || item.title : item.title}
331332
{item.label && (
332333
<div className="ml-2 flex gap-1">
333334
{castArray(item.label).map((label, labelIndex) => (

apps/www/src/components/logo.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use client';
2+
3+
import Link from 'next/link';
4+
5+
import { Button } from '@/components/ui/button';
6+
import { siteConfig } from '@/config/site';
7+
import { getLocalizedPath, useLocale } from '@/hooks/useLocale';
8+
9+
import { Icons } from './icons';
10+
11+
export function Logo() {
12+
const locale = useLocale();
13+
14+
return (
15+
<Button
16+
asChild
17+
size="icon"
18+
variant="ghost"
19+
className="hidden size-8 md:flex"
20+
>
21+
<Link href={getLocalizedPath(locale, '/')}>
22+
<Icons.logo className="size-5" />
23+
<span className="sr-only">{siteConfig.name}</span>
24+
</Link>
25+
</Button>
26+
);
27+
}

apps/www/src/components/main-nav.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { usePathname } from 'next/navigation';
99

1010
import { Button } from '@/components/ui/button';
1111
import { siteConfig } from '@/config/site';
12-
import { useLocale } from '@/hooks/useLocale';
12+
import { getLocalizedPath, useLocale } from '@/hooks/useLocale';
1313
import { cn } from '@/lib/utils';
1414

1515
import { Icons } from './icons';
@@ -46,9 +46,9 @@ export function MainNav({
4646
<Button key={item.href} asChild size="sm" variant="ghost">
4747
<Link
4848
className={cn(pathname === item.href && 'text-primary')}
49-
href={item.href!}
49+
href={getLocalizedPath(locale, item.href!)}
5050
>
51-
{item.label}
51+
{locale === 'cn' ? (item as any).labelCn || item.label : item.label}
5252
</Link>
5353
</Button>
5454
))}

apps/www/src/components/site-header.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { siteConfig } from '@/config/site';
88
import { CommandMenu } from './command-menu';
99
import { Icons } from './icons';
1010
import { LanguagesDropdownMenu } from './languages-dropdown-menu';
11+
import { Logo } from './logo';
1112
import { MainNav } from './main-nav';
1213
import { SetupMCPDialog } from './mcp-dialog';
1314
import { MobileNav } from './mobile-nav';
@@ -42,17 +43,7 @@ export function SiteHeader() {
4243
/>
4344

4445
{/* Desktop only */}
45-
<Button
46-
asChild
47-
size="icon"
48-
variant="ghost"
49-
className="hidden size-8 md:flex"
50-
>
51-
<Link href="/">
52-
<Icons.logo className="size-5" />
53-
<span className="sr-only">{siteConfig.name}</span>
54-
</Link>
55-
</Button>
46+
<Logo />
5647
<MainNav className="hidden md:flex" items={siteConfig.navItems} />
5748

5849
{/* Header end */}

apps/www/src/config/docs-api.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const docsApi: SidebarNavItem[] = [
1515
{
1616
href: '/docs/api/slate/editor-api',
1717
title: 'Editor API',
18+
titleCn: '编辑器 API',
1819
},
1920
{
2021
href: '/docs/api/slate/editor-transforms',
@@ -116,6 +117,7 @@ export const docsApi: SidebarNavItem[] = [
116117
],
117118
href: '/docs/api/core/plate-components',
118119
title: 'Plate Components',
120+
titleCn: 'Plate 组件',
119121
},
120122
{
121123
headings: [
@@ -148,6 +150,7 @@ export const docsApi: SidebarNavItem[] = [
148150
],
149151
href: '/docs/api/core/plate-editor',
150152
title: 'Plate Editor',
153+
titleCn: 'Plate 编辑器',
151154
},
152155
{
153156
headings: [
@@ -228,11 +231,13 @@ export const docsApi: SidebarNavItem[] = [
228231
],
229232
href: '/docs/api/core/plate-plugin',
230233
title: 'Plate Plugin',
234+
titleCn: 'Plate 插件',
231235
},
232236
{
233237
headings: ['useEventEditorSelectors', 'useEventPlateId'],
234238
href: '/docs/api/core/plate-store',
235239
title: 'Plate Store',
240+
titleCn: 'Plate 存储',
236241
},
237242
{
238243
headings: [
@@ -248,15 +253,18 @@ export const docsApi: SidebarNavItem[] = [
248253
],
249254
href: '/docs/api/core/plate-controller',
250255
title: 'Plate Controller',
256+
titleCn: 'Plate 控制器',
251257
},
252258
],
253259
title: 'Plate Core',
260+
titleCn: 'Plate 核心',
254261
},
255262
{
256263
description: 'Additional utilities for Plate.',
257264
headings: [],
258265
href: '/docs/api/utils',
259266
title: 'Plate Utils',
267+
titleCn: 'Plate 工具',
260268
},
261269
{
262270
description: 'React utilities.',
@@ -270,23 +278,27 @@ export const docsApi: SidebarNavItem[] = [
270278
],
271279
href: '/docs/api/react-utils',
272280
title: 'React Utils',
281+
titleCn: 'React 工具',
273282
},
274283
{
275284
description: 'Class utilities.',
276285
headings: ['cn', 'withCn', 'withProps', 'withVariants'],
277286
href: '/docs/api/cn',
278287
title: 'cn',
288+
titleCn: 'cn',
279289
},
280290
{
281291
description: 'API reference for @platejs/floating',
282292
headings: [],
283293
href: '/docs/api/floating',
284294
title: 'Floating',
295+
titleCn: 'Floating',
285296
},
286297
{
287298
description: 'API reference for @platejs/resizable',
288299
headings: [],
289300
href: '/docs/api/resizable',
290301
title: 'Resizable',
302+
titleCn: 'Resizable',
291303
},
292304
];

apps/www/src/config/docs-examples.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,58 @@ export const docsExamples: SidebarNavItem[] = [
1010
href: '/docs/examples/slate-to-html',
1111
label: 'New',
1212
title: 'Slate to HTML',
13+
titleCn: 'Slate 转 HTML',
1314
},
1415
{
1516
description: 'Export a Plate document to a file.',
1617
href: '/docs/examples/export',
1718
label: 'New',
1819
title: 'Export',
20+
titleCn: '导出',
1921
},
2022
{
2123
description: 'Server-side rendering.',
2224
href: '/docs/examples/server-side',
2325
title: 'Server-Side',
26+
titleCn: '服务端',
2427
},
2528
{
2629
description:
2730
"Show a diff of two different points in a Plate document's history.",
2831
href: '/docs/examples/version-history',
2932
title: 'Version History',
33+
titleCn: '版本历史',
3034
},
3135
{
3236
description: 'Nest editors in void nodes.',
3337
href: '/docs/examples/editable-voids',
3438
title: 'Editable Voids',
39+
titleCn: '可编辑的空节点',
3540
},
3641
{
3742
description: 'Rendering hundreds of blocks.',
3843
href: '/docs/examples/hundreds-blocks',
3944
title: 'Hundreds Blocks',
45+
titleCn: '数百个块',
4046
},
4147
{
4248
description: 'Render hundreds of editors.',
4349
href: '/docs/examples/hundreds-editors',
4450
title: 'Hundreds Editors',
51+
titleCn: '数百个编辑器',
4552
},
4653
{
4754
description: 'Decorate texts with markdown preview.',
4855
href: '/docs/examples/preview-markdown',
4956
title: 'Preview Markdown',
57+
titleCn: 'Markdown 预览',
5058
},
5159
{
5260
description: 'Collaborative editing.',
5361
href: '/docs/examples/collaboration',
5462
label: 'New',
5563
title: 'Collaboration Demo',
64+
titleCn: '协作演示',
5665
},
5766
...registryToNav(
5867
demoExamples.filter(

0 commit comments

Comments
 (0)