Skip to content

Commit 1407baf

Browse files
authored
docs: improve chinese translation (#3402)
1 parent 862b4be commit 1407baf

23 files changed

+202
-211
lines changed

docs/zh/guide/cms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ outline: deep
2424
```js
2525
export default {
2626
async paths() {
27-
// use respective CMS client library if needed
27+
// 如有需要,使用相应的 CMS 客户端库
2828
const data = await (await fetch('https://my-cms-api', {
2929
headers: {
30-
// token if necessary
30+
// 如有必要,可使用 token
3131
}
3232
})).json()
3333
3434
return data.map(entry => {
3535
return {
36-
params: { id: entry.id, /* title, authors, date etc. */ },
36+
params: { id: entry.id, /* title, authors, date */ },
3737
content: entry.content
3838
}
3939
})

docs/zh/guide/custom-theme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
```
88
.
9-
├─ docs # project root
9+
├─ docs # 项目根目录
1010
│ ├─ .vitepress
1111
│ │ ├─ theme
12-
│ │ │ └─ index.js # theme entry
13-
│ │ └─ config.js # config file
12+
│ │ │ └─ index.js # 主题入口
13+
│ │ └─ config.js # 配置文件
1414
│ └─ index.md
1515
└─ package.json
1616
```
@@ -24,26 +24,26 @@ VitePress 自定义主题是一个对象,该对象具有如下接口:
2424
```ts
2525
interface Theme {
2626
/**
27-
* Root layout component for every page
27+
* 每个页面的根布局组件
2828
* @required
2929
*/
3030
Layout: Component
3131
/**
32-
* Enhance Vue app instance
32+
* 增强 Vue 应用实例
3333
* @optional
3434
*/
3535
enhanceApp?: (ctx: EnhanceAppContext) => Awaitable<void>
3636
/**
37-
* Extend another theme, calling its `enhanceApp` before ours
37+
* 扩展另一个主题,在我们的主题之前调用它的 `enhanceApp`
3838
* @optional
3939
*/
4040
extends?: Theme
4141
}
4242

4343
interface EnhanceAppContext {
44-
app: App // Vue app instance
45-
router: Router // VitePress router instance
46-
siteData: Ref<SiteData> // Site-level metadata
44+
app: App // Vue 应用实例
45+
router: Router // VitePress 路由实例
46+
siteData: Ref<SiteData> // 站点级元数据
4747
}
4848
```
4949

@@ -52,8 +52,8 @@ interface EnhanceAppContext {
5252
```js
5353
// .vitepress/theme/index.js
5454

55-
// You can directly import Vue files in the theme entry
56-
// VitePress is pre-configured with @vitejs/plugin-vue.
55+
// 可以直接在主题入口导入 Vue 文件
56+
// VitePress 已预先配置 @vitejs/plugin-vue
5757
import Layout from './Layout.vue'
5858

5959
export default {
@@ -77,7 +77,7 @@ export default {
7777
<template>
7878
<h1>Custom Layout!</h1>
7979
80-
<!-- this is where markdown content will be rendered -->
80+
<!-- 此处将渲染 markdown 内容 -->
8181
<Content />
8282
</template>
8383
```
@@ -200,7 +200,7 @@ export default {
200200
import baseConfig from 'awesome-vitepress-theme/config'
201201

202202
export default {
203-
// extend theme base config (if needed)
203+
// 扩展主题的基本配置(如需要)
204204
extends: baseConfig
205205
}
206206
```
@@ -216,7 +216,7 @@ import type { ThemeConfig } from 'awesome-vitepress-theme'
216216
export default defineConfigWithTheme<ThemeConfig>({
217217
extends: baseConfig,
218218
themeConfig: {
219-
// Type is `ThemeConfig`
219+
// 类型为 `ThemeConfig`
220220
}
221221
})
222222
```

docs/zh/guide/data-loading.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { data } from './example.data.js'
4646
```js
4747
export default {
4848
async load() {
49-
// fetch remote data
49+
// 获取远程数据
5050
return (await fetch('...')).json()
5151
}
5252
}
@@ -67,9 +67,8 @@ import { parse } from 'csv-parse/sync'
6767
export default {
6868
watch: ['./data/*.csv'],
6969
load(watchedFiles) {
70-
// watchedFiles will be an array of absolute paths of the matched files.
71-
// generate an array of blog post metadata that can be used to render
72-
// a list in the theme layout
70+
// watchFiles 是一个所匹配文件的绝对路径的数组。
71+
// 生成一个博客文章元数据数组,可用于在主题布局中呈现列表。
7372
return watchedFiles.map((file) => {
7473
return parse(fs.readFileSync(file, 'utf-8'), {
7574
columns: true,
@@ -99,14 +98,14 @@ export default createContentLoader('posts/*.md', /* options */)
9998

10099
```ts
101100
interface ContentData {
102-
// mapped URL for the page. e.g. /posts/hello.html (does not include base)
103-
// manually iterate or use custom `transform` to normalize the paths
101+
// 页面的映射 URL,如 /posts/hello.html(不包括 base
102+
// 手动迭代或使用自定义 `transform` 来标准化路径
104103
url: string
105-
// frontmatter data of the page
104+
// 页面的 frontmatter 数据
106105
frontmatter: Record<string, any>
107106

108-
// the following are only present if relevant options are enabled
109-
// we will discuss them below
107+
// 只有启用了相关选项,才会出现以下内容
108+
// 我们将在下面讨论它们
110109
src: string | undefined
111110
html: string | undefined
112111
excerpt: string | undefined
@@ -140,18 +139,18 @@ import { data as posts } from './posts.data.js'
140139
import { createContentLoader } from 'vitepress'
141140

142141
export default createContentLoader('posts/*.md', {
143-
includeSrc: true, // include raw markdown source?
144-
render: true, // include rendered full page HTML?
145-
excerpt: true, // include excerpt?
142+
includeSrc: true, // 包含原始 markdown ?
143+
render: true, // 包含渲染的整页 HTML?
144+
excerpt: true, // 包含摘录?
146145
transform(rawData) {
147-
// map, sort, or filter the raw data as you wish.
148-
// the final result is what will be shipped to the client.
146+
// 根据需要对原始数据进行 map、sort filter
147+
// 最终的结果是将发送给客户端的内容
149148
return rawData.sort((a, b) => {
150149
return +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date)
151150
}).map((page) => {
152-
page.src // raw markdown source
153-
page.html // rendered full page HTML
154-
page.excerpt // rendered excerpt HTML (content above first `---`)
151+
page.src // 原始 markdown
152+
page.html // 渲染的整页 HTML
153+
page.excerpt // 渲染的摘录 HTML(第一个 `---` 上面的内容)
155154
return {/* ... */}
156155
})
157156
}
@@ -167,7 +166,7 @@ export default createContentLoader('posts/*.md', {
167166
export default {
168167
async buildEnd() {
169168
const posts = await createContentLoader('posts/*.md').load()
170-
// generate files based on posts metadata, e.g. RSS feed
169+
// 根据 posts 元数据生成文件,如 RSS 订阅源
171170
}
172171
}
173172
```
@@ -177,24 +176,24 @@ export default {
177176
```ts
178177
interface ContentOptions<T = ContentData[]> {
179178
/**
180-
* Include src?
179+
* 包含 src?
181180
* @default false
182181
*/
183182
includeSrc?: boolean
184183

185184
/**
186-
* Render src to HTML and include in data?
185+
* src 渲染为 HTML 并包含在数据中?
187186
* @default false
188187
*/
189188
render?: boolean
190189

191190
/**
192-
* If `boolean`, whether to parse and include excerpt? (rendered as HTML)
191+
* 如果为 `boolean`,是否解析并包含摘录? (呈现为 HTML)
193192
*
194-
* If `function`, control how the excerpt is extracted from the content.
193+
* 如果为 `function`,则控制如何从内容中提取摘录
195194
*
196-
* If `string`, define a custom separator to be used for extracting the
197-
* excerpt. Default separator is `---` if `excerpt` is `true`.
195+
* 如果为 `string`,则定义用于提取摘录的自定义分隔符
196+
* 如果 `excerpt` 为 `true`,则默认分隔符为 `---`
198197
*
199198
* @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt
200199
* @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt_separator
@@ -207,8 +206,7 @@ interface ContentOptions<T = ContentData[]> {
207206
| string
208207

209208
/**
210-
* Transform the data. Note the data will be inlined as JSON in the client
211-
* bundle if imported from components or markdown files.
209+
* 转换数据。请注意,如果从组件或 Markdown 文件导入,数据将以 JSON 形式内联到客户端包中
212210
*/
213211
transform?: (data: ContentData[]) => T | Promise<T>
214212
}
@@ -222,14 +220,14 @@ interface ContentOptions<T = ContentData[]> {
222220
import { defineLoader } from 'vitepress'
223221

224222
export interface Data {
225-
// data type
223+
// data 类型
226224
}
227225

228226
declare const data: Data
229227
export { data }
230228

231229
export default defineLoader({
232-
// type checked loader options
230+
// 类型检查加载器选项
233231
watch: ['...'],
234232
async load(): Promise<Data> {
235233
// ...

docs/zh/guide/deploy.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,61 +122,61 @@ Cache-Control: max-age=31536000,immutable
122122
1. 在项目的 `.github/workflows` 目录中创建一个名为 `deploy.yml` 的文件,其中包含这样的内容:
123123

124124
```yaml
125-
# Sample workflow for building and deploying a VitePress site to GitHub Pages
125+
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
126126
#
127127
name: Deploy VitePress site to Pages
128128

129129
on:
130-
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
131-
# using the `master` branch as the default branch.
130+
# 在针对 `main` 分支的推送上运行。如果您
131+
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
132132
push:
133133
branches: [main]
134134

135-
# Allows you to run this workflow manually from the Actions tab
135+
# 允许您从 Actions 选项卡手动运行此工作流程
136136
workflow_dispatch:
137137

138-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
138+
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
139139
permissions:
140140
contents: read
141141
pages: write
142142
id-token: write
143143

144-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
145-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
144+
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
145+
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
146146
concurrency:
147147
group: pages
148148
cancel-in-progress: false
149149

150150
jobs:
151-
# Build job
151+
# 构建工作
152152
build:
153153
runs-on: ubuntu-latest
154154
steps:
155155
- name: Checkout
156156
uses: actions/checkout@v3
157157
with:
158-
fetch-depth: 0 # Not needed if lastUpdated is not enabled
159-
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
160-
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
158+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
159+
# - uses: pnpm/action-setup@v2 # 如果使用 pnpm,请取消注释
160+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
161161
- name: Setup Node
162162
uses: actions/setup-node@v3
163163
with:
164164
node-version: 18
165-
cache: npm # or pnpm / yarn
165+
cache: npm # pnpm / yarn
166166
- name: Setup Pages
167167
uses: actions/configure-pages@v3
168168
- name: Install dependencies
169-
run: npm ci # or pnpm install / yarn install / bun install
169+
run: npm ci # pnpm install / yarn install / bun install
170170
- name: Build with VitePress
171171
run: |
172-
npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
172+
npm run docs:build # pnpm docs:build / yarn docs:build / bun run docs:build
173173
touch docs/.vitepress/dist/.nojekyll
174174
- name: Upload artifact
175175
uses: actions/upload-pages-artifact@v2
176176
with:
177177
path: docs/.vitepress/dist
178178

179-
# Deployment job
179+
# 部署工作
180180
deploy:
181181
environment:
182182
name: github-pages
@@ -211,7 +211,7 @@ Cache-Control: max-age=31536000,immutable
211211
paths:
212212
- node_modules/
213213
script:
214-
# - apk add git # Uncomment this if you're using small docker images like alpine and have lastUpdated enabled
214+
# - apk add git # 如果你使用的是像 alpine 这样的小型 docker 镜像,并且启用了 lastUpdated,请取消注释
215215
- npm install
216216
- npm run docs:build
217217
artifacts:

docs/zh/guide/extending-default-theme.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default DefaultTheme
7272
// .vitepress/config.js
7373
export default {
7474
transformHead({ assets }) {
75-
// adjust the regex accordingly to match your font
75+
// 相应地调整正则表达式以匹配字体
7676
const myFontFile = assets.find(file => /font-name\.\w+\.woff2/)
7777
if (myFontFile) {
7878
return [
@@ -102,7 +102,7 @@ import DefaultTheme from 'vitepress/theme'
102102
export default {
103103
extends: DefaultTheme,
104104
enhanceApp({ app }) {
105-
// register your custom global components
105+
// 注册自定义全局组件
106106
app.component('MyGlobalComponent' /* ... */)
107107
}
108108
}
@@ -117,7 +117,7 @@ import DefaultTheme from 'vitepress/theme'
117117
export default {
118118
extends: DefaultTheme,
119119
enhanceApp({ app }) {
120-
// register your custom global components
120+
// 注册自定义全局组件
121121
app.component('MyGlobalComponent' /* ... */)
122122
}
123123
} satisfies Theme
@@ -136,8 +136,7 @@ import MyLayout from './MyLayout.vue'
136136

137137
export default {
138138
extends: DefaultTheme,
139-
// override the Layout with a wrapper component that
140-
// injects the slots
139+
// 使用注入插槽的包装组件覆盖 Layout
141140
Layout: MyLayout
142141
}
143142
```

docs/zh/guide/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ $ bunx vitepress init
115115
```js
116116
// .vitepress/config.js
117117
export default {
118-
// site-level options
118+
// 站点级选项
119119
title: 'VitePress',
120120
description: 'Just playing around.',
121121

122122
themeConfig: {
123-
// theme-level options
123+
// 主题级选项
124124
}
125125
}
126126
```

0 commit comments

Comments
 (0)