Skip to content

Commit 3052002

Browse files
vanchKongawxiaoxian2020shellRainingbrc-dd
authored
docs: add Chinese translations (#2249)
--------- Co-authored-by: Xavi Lee <[email protected]> Co-authored-by: shellRaining <[email protected]> Co-authored-by: Xavi Lee <[email protected]> Co-authored-by: Divyansh Singh <[email protected]>
1 parent 7735631 commit 3052002

Some content is hidden

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

46 files changed

+6972
-129
lines changed

Diff for: docs/.vitepress/config.ts renamed to docs/.vitepress/config/en.ts

+5-58
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,11 @@ import { defineConfig, type DefaultTheme } from 'vitepress'
44
const require = createRequire(import.meta.url)
55
const pkg = require('vitepress/package.json')
66

7-
export default defineConfig({
7+
export const en = defineConfig({
88
lang: 'en-US',
9-
title: 'VitePress',
109
description: 'Vite & Vue powered static site generator.',
1110

12-
lastUpdated: true,
13-
cleanUrls: true,
14-
15-
markdown: {
16-
math: true,
17-
codeTransformers: [
18-
// We use `[!!code` in demo to prevent transformation, here we revert it back.
19-
{
20-
postprocess(code) {
21-
return code.replace(/\[\!\!code/g, '[!code')
22-
}
23-
}
24-
]
25-
},
26-
27-
sitemap: {
28-
hostname: 'https://vitepress.dev',
29-
transformItems(items) {
30-
return items.filter((item) => !item.url.includes('migration'))
31-
}
32-
},
33-
34-
/* prettier-ignore */
35-
head: [
36-
['link', { rel: 'icon', type: 'image/svg+xml', href: '/vitepress-logo-mini.svg' }],
37-
['link', { rel: 'icon', type: 'image/png', href: '/vitepress-logo-mini.png' }],
38-
['meta', { name: 'theme-color', content: '#5f67ee' }],
39-
['meta', { name: 'og:type', content: 'website' }],
40-
['meta', { name: 'og:locale', content: 'en' }],
41-
['meta', { name: 'og:site_name', content: 'VitePress' }],
42-
['meta', { name: 'og:image', content: 'https://vitepress.dev/vitepress-og.jpg' }],
43-
['script', { src: 'https://cdn.usefathom.com/script.js', 'data-site': 'AZBRSFGG', 'data-spa': 'auto', defer: '' }]
44-
],
45-
4611
themeConfig: {
47-
logo: { src: '/vitepress-logo-mini.svg', width: 24, height: 24 },
48-
4912
nav: nav(),
5013

5114
sidebar: {
@@ -58,27 +21,9 @@ export default defineConfig({
5821
text: 'Edit this page on GitHub'
5922
},
6023

61-
socialLinks: [
62-
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
63-
],
64-
6524
footer: {
6625
message: 'Released under the MIT License.',
6726
copyright: 'Copyright © 2019-present Evan You'
68-
},
69-
70-
search: {
71-
provider: 'algolia',
72-
options: {
73-
appId: '8J64VVRP8K',
74-
apiKey: 'a18e2f4cc5665f6602c5631fd868adfd',
75-
indexName: 'vitepress'
76-
}
77-
},
78-
79-
carbonAds: {
80-
code: 'CEBDT27Y',
81-
placement: 'vuejsorg'
8227
}
8328
}
8429
})
@@ -111,7 +56,6 @@ function nav(): DefaultTheme.NavItem[] {
11156
]
11257
}
11358

114-
/* prettier-ignore */
11559
function sidebarGuide(): DefaultTheme.SidebarItem[] {
11660
return [
11761
{
@@ -140,7 +84,10 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
14084
collapsed: false,
14185
items: [
14286
{ text: 'Using a Custom Theme', link: 'custom-theme' },
143-
{ text: 'Extending the Default Theme', link: 'extending-default-theme' },
87+
{
88+
text: 'Extending the Default Theme',
89+
link: 'extending-default-theme'
90+
},
14491
{ text: 'Build-Time Data Loading', link: 'data-loading' },
14592
{ text: 'SSR Compatibility', link: 'ssr-compat' },
14693
{ text: 'Connecting to a CMS', link: 'cms' }

Diff for: docs/.vitepress/config/index.ts

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { defineConfig } from 'vitepress'
2+
import { en } from './en'
3+
import { zh, search as zhSearch } from './zh'
4+
5+
export default defineConfig({
6+
title: 'VitePress',
7+
8+
lastUpdated: true,
9+
cleanUrls: true,
10+
11+
markdown: {
12+
math: true,
13+
codeTransformers: [
14+
// We use `[!!code` in demo to prevent transformation, here we revert it back.
15+
{
16+
postprocess(code) {
17+
return code.replace(/\[\!\!code/g, '[!code')
18+
}
19+
}
20+
]
21+
},
22+
23+
sitemap: {
24+
hostname: 'https://vitepress.dev',
25+
transformItems(items) {
26+
return items.filter((item) => !item.url.includes('migration'))
27+
}
28+
},
29+
30+
/* prettier-ignore */
31+
head: [
32+
['link', { rel: 'icon', type: 'image/svg+xml', href: '/vitepress-logo-mini.svg' }],
33+
['link', { rel: 'icon', type: 'image/png', href: '/vitepress-logo-mini.png' }],
34+
['meta', { name: 'theme-color', content: '#5f67ee' }],
35+
['meta', { name: 'og:type', content: 'website' }],
36+
['meta', { name: 'og:locale', content: 'en' }],
37+
['meta', { name: 'og:site_name', content: 'VitePress' }],
38+
['meta', { name: 'og:image', content: 'https://vitepress.dev/vitepress-og.jpg' }],
39+
['script', { src: 'https://cdn.usefathom.com/script.js', 'data-site': 'AZBRSFGG', 'data-spa': 'auto', defer: '' }]
40+
],
41+
42+
themeConfig: {
43+
logo: { src: '/vitepress-logo-mini.svg', width: 24, height: 24 },
44+
45+
socialLinks: [
46+
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
47+
],
48+
49+
search: {
50+
provider: 'algolia',
51+
options: {
52+
appId: '8J64VVRP8K',
53+
apiKey: 'a18e2f4cc5665f6602c5631fd868adfd',
54+
indexName: 'vitepress',
55+
locales: { ...zhSearch }
56+
}
57+
},
58+
59+
carbonAds: { code: 'CEBDT27Y', placement: 'vuejsorg' }
60+
},
61+
62+
locales: {
63+
root: { label: 'English', ...en },
64+
zh: { label: '简体中文', ...zh }
65+
}
66+
})

Diff for: docs/.vitepress/config/zh.ts

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import { createRequire } from 'module'
2+
import { defineConfig, type DefaultTheme } from 'vitepress'
3+
4+
const require = createRequire(import.meta.url)
5+
const pkg = require('vitepress/package.json')
6+
7+
export const zh = defineConfig({
8+
lang: 'zh-Hans',
9+
description: '由 Vite 和 Vue 驱动的静态站点生成器',
10+
11+
themeConfig: {
12+
nav: nav(),
13+
14+
sidebar: {
15+
'/zh/guide/': { base: '/zh/guide/', items: sidebarGuide() },
16+
'/zh/reference/': { base: '/zh/reference/', items: sidebarReference() }
17+
},
18+
19+
editLink: {
20+
pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
21+
text: '在 GitHub 上编辑此页面'
22+
},
23+
24+
footer: {
25+
message: '根据 MIT 许可发布。',
26+
copyright: '版权所有 © 2019 至今 尤雨溪'
27+
},
28+
29+
docFooter: {
30+
prev: '上一页',
31+
next: '下一页'
32+
},
33+
34+
outline: {
35+
label: '页面导航'
36+
},
37+
38+
lastUpdated: {
39+
text: '最后更新于',
40+
formatOptions: {
41+
dateStyle: 'short',
42+
timeStyle: 'medium'
43+
}
44+
},
45+
46+
langMenuLabel: '多语言',
47+
returnToTopLabel: '回到顶部',
48+
sidebarMenuLabel: '菜单',
49+
darkModeSwitchLabel: '主题',
50+
lightModeSwitchTitle: '切换到浅色模式',
51+
darkModeSwitchTitle: '切换到深色模式'
52+
}
53+
})
54+
55+
function nav(): DefaultTheme.NavItem[] {
56+
return [
57+
{
58+
text: '指南',
59+
link: '/zh/guide/what-is-vitepress',
60+
activeMatch: '/zh/guide/'
61+
},
62+
{
63+
text: '参考',
64+
link: '/zh/reference/site-config',
65+
activeMatch: '/zh/reference/'
66+
},
67+
{
68+
text: pkg.version,
69+
items: [
70+
{
71+
text: '更新日志',
72+
link: 'https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md'
73+
},
74+
{
75+
text: '参与贡献',
76+
link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md'
77+
}
78+
]
79+
}
80+
]
81+
}
82+
83+
function sidebarGuide(): DefaultTheme.SidebarItem[] {
84+
return [
85+
{
86+
text: '简介',
87+
collapsed: false,
88+
items: [
89+
{ text: '什么是 VitePress?', link: 'what-is-vitepress' },
90+
{ text: '快速开始', link: 'getting-started' },
91+
{ text: '路由', link: 'routing' },
92+
{ text: '部署', link: 'deploy' }
93+
]
94+
},
95+
{
96+
text: '写作',
97+
collapsed: false,
98+
items: [
99+
{ text: 'Markdown 扩展', link: 'markdown' },
100+
{ text: '资源处理', link: 'asset-handling' },
101+
{ text: 'frontmatter', link: 'frontmatter' },
102+
{ text: '在 Markdown 使用 Vue', link: 'using-vue' },
103+
{ text: '国际化', link: 'i18n' }
104+
]
105+
},
106+
{
107+
text: '自定义',
108+
collapsed: false,
109+
items: [
110+
{ text: '自定义主题', link: 'custom-theme' },
111+
{ text: '扩展默认主题', link: 'extending-default-theme' },
112+
{ text: '构建时数据加载', link: 'data-loading' },
113+
{ text: 'SSR 兼容性', link: 'ssr-compat' },
114+
{ text: '连接 CMS', link: 'cms' }
115+
]
116+
},
117+
{
118+
text: '实验性功能',
119+
collapsed: false,
120+
items: [
121+
{ text: 'MPA 模式', link: 'mpa-mode' },
122+
{ text: 'sitemap 生成', link: 'sitemap-generation' }
123+
]
124+
},
125+
{ text: '配置和 API 参考', base: '/zh/reference/', link: 'site-config' }
126+
]
127+
}
128+
129+
function sidebarReference(): DefaultTheme.SidebarItem[] {
130+
return [
131+
{
132+
text: '参考',
133+
items: [
134+
{ text: '站点配置', link: 'site-config' },
135+
{ text: 'frontmatter 配置', link: 'frontmatter-config' },
136+
{ text: '运行时 API', link: 'runtime-api' },
137+
{ text: 'CLI', link: 'cli' },
138+
{
139+
text: '默认主题',
140+
base: '/zh/reference/default-theme-',
141+
items: [
142+
{ text: '概览', link: 'config' },
143+
{ text: '导航栏', link: 'nav' },
144+
{ text: '侧边栏', link: 'sidebar' },
145+
{ text: '主页', link: 'home-page' },
146+
{ text: '页脚', link: 'footer' },
147+
{ text: '布局', link: 'layout' },
148+
{ text: '徽章', link: 'badge' },
149+
{ text: '团队页', link: 'team-page' },
150+
{ text: '上下页链接', link: 'prev-next-links' },
151+
{ text: '编辑链接', link: 'edit-link' },
152+
{ text: '最后更新时间戳', link: 'last-updated' },
153+
{ text: '搜索', link: 'search' },
154+
{ text: 'Carbon Ads', link: 'carbon-ads' }
155+
]
156+
}
157+
]
158+
}
159+
]
160+
}
161+
162+
export const search: DefaultTheme.AlgoliaSearchOptions['locales'] = {
163+
zh: {
164+
placeholder: '搜索文档',
165+
translations: {
166+
button: {
167+
buttonText: '搜索文档',
168+
buttonAriaLabel: '搜索文档'
169+
},
170+
modal: {
171+
searchBox: {
172+
resetButtonTitle: '清除查询条件',
173+
resetButtonAriaLabel: '清除查询条件',
174+
cancelButtonText: '取消',
175+
cancelButtonAriaLabel: '取消'
176+
},
177+
startScreen: {
178+
recentSearchesTitle: '搜索历史',
179+
noRecentSearchesText: '没有搜索历史',
180+
saveRecentSearchButtonTitle: '保存至搜索历史',
181+
removeRecentSearchButtonTitle: '从搜索历史中移除',
182+
favoriteSearchesTitle: '收藏',
183+
removeFavoriteSearchButtonTitle: '从收藏中移除'
184+
},
185+
errorScreen: {
186+
titleText: '无法获取结果',
187+
helpText: '你可能需要检查你的网络连接'
188+
},
189+
footer: {
190+
selectText: '选择',
191+
navigateText: '切换',
192+
closeText: '关闭',
193+
searchByText: '搜索提供者'
194+
},
195+
noResultsScreen: {
196+
noResultsText: '无法找到相关结果',
197+
suggestedQueryText: '你可以尝试查询',
198+
reportMissingResultsText: '你认为该查询应该有结果?',
199+
reportMissingResultsLinkText: '点击反馈'
200+
}
201+
}
202+
}
203+
}
204+
}

0 commit comments

Comments
 (0)