Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n #3898

Merged
merged 27 commits into from
Dec 24, 2024
Merged

I18n #3898

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
site
  • Loading branch information
felixfeng33 committed Dec 22, 2024
commit 81346dca399d6e91c604e42f6ac82d4c8b7d80ab
2 changes: 1 addition & 1 deletion apps/www/content/cn/docs/components/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Which frameworks are supported?
## 致谢

- [shadcn/ui](https://ui.shadcn.com/) - 用于 UI、文档和 CLI。
- [Radix UI](https://radix-ui.com) - 用于原语。
- [Radix UI](https://radix-ui.com) - 用于原语(primitive)
- [Vercel](https://vercel.com) - 用于托管。
- [Shu Ding](https://shud.in) - 排版样式是基于他在 Nextra 上的工作。
- [cmdk](https://cmdk.paco.me) - 用于 `<Command />` 组件。
12 changes: 6 additions & 6 deletions apps/www/content/cn/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ npm install @udecode/plate-common slate slate-dom slate-react slate-history
npm install @udecode/plate-basic-marks @udecode/plate-heading @udecode/plate-block-quote @udecode/cn
```

- `@udecode/plate-basic-marks` provides bold, italic, underline, and code formatting.
- `@udecode/plate-heading` adds h1-h6 support.
- `@udecode/plate-block-quote` adds blockquote support.
- `@udecode/cn` helps with component styling (optional).
- `@udecode/plate-basic-marks` 提供粗体、斜体、下划线和代码格式化功能。
- `@udecode/plate-heading` 添加 h1-h6 标题支持。
- `@udecode/plate-block-quote` 添加引用块支持。
- `@udecode/cn` 帮助组件样式设置(可选)。

### 基本编辑器

Expand Down Expand Up @@ -144,7 +144,7 @@ export default function BasicEditor() {

<ComponentPreview name="basic-editor-handler-demo" padding="md" />

### Plugins
### 插件

<Callout className="my-4">
查看 [Plugins](/docs/plugins) 部分中的完整插件列表。
Expand Down Expand Up @@ -195,7 +195,7 @@ export default function BasicEditor() {
**注意**: 你不需要添加核心插件,如 **`ReactPlugin`**、**`HistoryPlugin`** 和 **`ParagraphPlugin`**,因为 **`usePlateEditor`** 已经为你做了。
</Callout>

### Components
### 组件

<Callout className="mt-4">
**注意**: Plate 插件是未样式化的,这意味着你可以完全控制标记和样式,因此你可以集成你自己的设计系统或 [Plate UI](/docs/components)。
Expand Down
6 changes: 3 additions & 3 deletions apps/www/content/cn/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Introduction
description: 用于 React 的富文本编辑器框架。
---

Plate 是一个强大的工具包,可以让你更轻松地使用 [Slate](https://docs.slatejs.org/)(一个流行的文本编辑器构建框架)进行开发。Plate 主要关注四个方面:**核心**、**插件**、**原语**和**组件**。
Plate 是一个强大的工具包,可以让你更轻松地使用 [Slate](https://docs.slatejs.org/)(一个流行的文本编辑器构建框架)进行开发。Plate 主要关注四个方面:**核心**、**插件**、**原语(primitive)**和**组件**。

## 核心

Expand All @@ -18,7 +18,7 @@ Plate 提供了广泛的插件包,用于增强编辑器的行为、钩子、
- **API 和转换**:插件可以定义自己的 API 方法和转换,通过 `editor.api` 和 `editor.transforms` 访问。
- **TypeScript**:为插件和编辑器提供强大的类型推断。

## 原语
## 原语(primitive)

除了插件外,Plate 还提供基于 [Radix UI](https://www.radix-ui.com/) 的无样式和可访问的组件。这些组件作为构建高质量设计系统的基础。

Expand Down Expand Up @@ -57,7 +57,7 @@ Plate 提供了广泛的插件包,用于增强编辑器的行为、钩子、
## 致谢

- [shadcn/ui](https://ui.shadcn.com/) - 提供 UI、文档和 CLI。
- [Radix UI](https://radix-ui.com) - 提供原语。
- [Radix UI](https://radix-ui.com) - 提供原语(primitive)
- [Vercel](https://vercel.com) - 提供托管。
- [Shu Ding](https://shud.in) - 排版样式改编自他在 [Nextra](https://nextra.site) 上的工作。
- [cmdk](https://cmdk.paco.me) - 提供 `<Command />` 组件。
17 changes: 16 additions & 1 deletion apps/www/contentlayer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { visit } from 'unist-util-visit';
import { rehypeComponent } from './src/lib/rehype-component';
import { rehypeNpmCommand } from './src/lib/rehype-npm-command';

import 'dotenv/config';

/** @type {import('contentlayer2/source-files').ComputedFields} */
const computedFields = {
slug: {
Expand Down Expand Up @@ -94,8 +96,21 @@ export const Doc = defineDocumentType(() => ({
name: 'Doc',
}));

const getContentDirPath = () => {
const languageToPath = {
Chinese: './content/cn',
English: './content/en',
Japanese: './content/jp',
Korean: './content/kr',
};

const language = process.env.NEXT_PUBLIC_LANGUAGE;

return languageToPath[language] ?? './content/en';
};

export default makeSource({
contentDirPath: './content/cn',
contentDirPath: getContentDirPath(),
documentTypes: [Doc],
mdx: {
rehypePlugins: [
Expand Down
1 change: 1 addition & 0 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"cmdk": "^1.0.0",
"contentlayer2": "^0.4.6",
"date-fns": "^3.6.0",
"dotenv": "16.4.7",
"framer-motion": "^11.5.4",
"fzf": "0.5.2",
"html2canvas": "^1.4.1",
Expand Down
14 changes: 13 additions & 1 deletion apps/www/src/app/(app)/_components/announcement-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ import * as React from 'react';
import { ArrowRightIcon } from 'lucide-react';

import { Button } from '@/registry/default/plate-ui/button';
import { getI18nContent } from '@/utils/getI18nConent';

const i18n = {
Chinese: {
description: 'AI, Copilot, 上传, 数学, 以及更多',
},
English: {
description: 'AI, Copilot, Upload, Math, and more',
},
};

export function AnnouncementButton() {
const content = getI18nContent(i18n);

return (
<Button
size="lg"
Expand All @@ -19,7 +31,7 @@ export function AnnouncementButton() {
{/* <SparklesIcon />
<Separator orientation="vertical" className="mx-2 h-4" /> */}
<span className="whitespace-break-spaces underline-offset-4 group-hover:underline">
<span>AI, Copilot, Upload, Math, and more</span>
<span>{content.description}</span>
{/* <span className="bg-gradient-to-r from-[#6EB6F2] via-[#a855f7] to-[#eab308] bg-clip-text text-transparent">
Plate Plus
</span> */}
Expand Down
22 changes: 19 additions & 3 deletions apps/www/src/app/(app)/_components/home-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@ import { settingsStore } from '@/components/context/settings-store';
import { PlaygroundPreview } from '@/components/playground-preview';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Button } from '@/registry/default/plate-ui/button';
import { getI18nContent } from '@/utils/getI18nConent';

const i18n = {
Chinese: {
customize: '定制',
installation: '安装',
playground: '操场',
},
English: {
customize: 'Customize',
installation: 'Installation',
playground: 'Playground',
},
};

const InstallationTab = dynamic(() => import('./installation-tab'));

export default function HomeTabs() {
const content = getI18nContent(i18n);

const active = settingsStore.use.showSettings();
const homeTab = settingsStore.use.homeTab();
const [builder, setBuilder] = useQueryState(
Expand Down Expand Up @@ -45,8 +61,8 @@ export default function HomeTabs() {
}}
>
<TabsList>
<TabsTrigger value="playground">Playground</TabsTrigger>
<TabsTrigger value="installation">Installation</TabsTrigger>
<TabsTrigger value="playground">{content.playground}</TabsTrigger>
<TabsTrigger value="installation">{content.installation}</TabsTrigger>
</TabsList>

<Button
Expand All @@ -66,7 +82,7 @@ export default function HomeTabs() {
}}
>
<Settings2 className="size-4" />
Customize
{content.customize}
</Button>

<TabsContent className="pt-2" value="playground">
Expand Down
Loading
Loading