Skip to content

Commit bc4bb5d

Browse files
Lzzzssxzz
andauthored
docs: translate Chinese docs (#250)
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
1 parent 6cf0efd commit bc4bb5d

22 files changed

+208
-188
lines changed

docs/.vitepress/locales/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ gtag('config', 'G-29NKGSL23C');`,
3030
],
3131
]
3232

33-
export const sidebar = (lang: string): DefaultTheme.Sidebar => {
33+
export const sidebar = (lang: string): DefaultTheme.SidebarItem[] => {
3434
const urlPrefix = lang ? `/${lang}` : ''
3535
return [
3636
{

docs/.vitepress/locales/zh-cn.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ export const nav: DefaultTheme.NavItem[] = [
1212

1313
export const sidebar = common.sidebar('zh-CN')
1414

15+
const sidebarTitle: string[] = ['指南', '宏', '特性']
16+
const sidebarItem: string[][] = [
17+
['入门', '打包器整合', 'Nuxt 整合', '配置'],
18+
['全部宏'],
19+
[''],
20+
]
21+
sidebar.forEach((bar, i) => {
22+
bar.text = sidebarTitle[i]
23+
bar.items!.forEach((item, j) => {
24+
if (sidebarItem[i][j]) item.text = sidebarItem[i][j]
25+
})
26+
})
27+
1528
export const themeConfig: DefaultTheme.Config = {
1629
...common.themeConfig,
1730

docs/zh-CN/features/better-define.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# betterDefine
22

3-
<small>Stability: <code class="!text-green-600">stable</code></small>
3+
<small>稳定性: <code class="!text-green-600">稳定</code></small>
44

5-
With enabling `betterDefine`, imported types are supported in `<script setup>` type-based-macros.
5+
通过开启 `betterDefine` ,支持在 `<script setup>` 中导入 TS 类型来定义 `props``emits`
66

7-
[Related issue](https://github.com/vuejs/core/issues/4294)
7+
如果你对此功能有任何疑问,欢迎在 [issues](https://github.com/vuejs/core/issues/4294) 中发表评论。
88

9-
| Features | Supported |
9+
| 特性 | 支持 |
1010
| :--------: | :----------------: |
1111
| Vue 3 | :white_check_mark: |
1212
| Nuxt 3 | :white_check_mark: |
1313
| Vue 2 | :white_check_mark: |
1414
| TypeScript | :white_check_mark: |
1515

16-
## Basic Usage
16+
## 基本用法
1717

1818
::: code-group
1919

@@ -36,29 +36,29 @@ export interface BaseProps {
3636

3737
:::
3838

39-
## ⚠️ Limitations
39+
## ⚠️ 限制
4040

41-
### Complex types
41+
### 复杂类型
4242

43-
Complex types are not supported in some key places. For example:
43+
在一些**关键的位置**不支持**复杂类型**。例如:
4444

45-
#### What are Complex Types?
45+
#### 什么是复杂类型?
4646

47-
- All utility types
48-
- [Built-in types](https://www.typescriptlang.org/docs/handbook/utility-types.html)
49-
- All types from `type-fest` package.
47+
- 所有工具类型
48+
- [内置类型](https://www.typescriptlang.org/docs/handbook/utility-types.html)
49+
- 来自 `type-fest` 包的所有类型。
5050
- ...
51-
- Index Signature
51+
- 索引签名
5252
```ts
5353
interface Type {
5454
[key: string]: string
5555
}
5656
```
57-
- Generics will be ignored directly
57+
- 泛型将会被直接忽略
5858

59-
#### What are Key Places?
59+
#### 什么是**关键的位置**?
6060

61-
- The names of props.
61+
- **props** 的名称
6262

6363
```ts
6464
//
@@ -72,7 +72,7 @@ defineProps<{
7272
}>()
7373
```
7474

75-
- The names of events.
75+
- **events** 的名称
7676

7777
```ts
7878
interface Emits {

docs/zh-CN/features/export-props.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# exportProps
22

3-
<small py2>Stability: <code class="!text-red-600">experimental</code></small>
3+
<div py2 flex>
4+
<small>稳定性: <code class="!text-red-600">实验性</code></small>
5+
<WarnBadge>实验性功能,风险自负</WarnBadge>
6+
</div>
47

5-
[Svelte-like Declaring props](https://svelte.dev/docs#component-format-script-1-export-creates-a-component-prop) for Vue.
8+
在 Vue 中像 Svelte 那样声明 `props`[Svelte 对应文档](https://svelte.dev/docs#component-format-script-1-export-creates-a-component-prop)
69

7-
| Features | Supported |
10+
| 特性 | 支持 |
811
| :----------: | :----------------: |
912
| Vue 3 | :white_check_mark: |
1013
| Nuxt 3 | ? |
1114
| Vue 2 | ? |
1215
| Volar Plugin | :white_check_mark: |
1316

14-
## Usage
17+
## 用法
1518

16-
Using export syntax to declare props.
19+
使用导出的语法来声明 `props`
1720

1821
```vue
1922
<script setup lang="ts">

docs/zh-CN/features/hoist-static.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# hoistStatic
22

3-
<small>Stability: <code class="!text-green-600">stable</code></small>
3+
<small>稳定性: <code class="!text-green-600">稳定</code></small>
44

5-
With enabling `hoistStatic`, constants declared in macros of `<script setup>` can be referenced.
5+
<!-- 通过开启 `hoistStatic`, 你可以引用 `<script setup>` 宏中声明的常量。 -->
66

7-
If you support this feature, feel free to hit like :+1: or comment on the [Vue PR](https://github.com/vuejs/core/pull/5752). Thanks!
7+
通过开启 `hoistStatic`, 可以在宏内部引用 `<script setup>` 中的变量
88

9-
| Features | Supported |
10-
| :------: | :----------------: |
11-
| Vue 3 | :white_check_mark: |
12-
| Nuxt 3 | :white_check_mark: |
13-
| Vue 2 | :white_check_mark: |
9+
如果你支持此功能,欢迎在 [Vue PR](https://github.com/vuejs/core/pull/5752) 中点赞 :+1: 或发表评论。
1410

15-
## Basic Usage
11+
| 特性 | 支持 |
12+
| :----: | :----------------: |
13+
| Vue 3 | :white_check_mark: |
14+
| Nuxt 3 | :white_check_mark: |
15+
| Vue 2 | :white_check_mark: |
16+
17+
## 基本用法
1618

1719
```vue
1820
<script setup lang="ts">
@@ -23,7 +25,7 @@ defineOptions({
2325
</script>
2426
```
2527

26-
::: details Compiled Code
28+
::: details 编译后代码
2729

2830
```vue
2931
<script lang="ts">
@@ -36,7 +38,7 @@ export default {
3638

3739
:::
3840

39-
## Magic Comments
41+
## 魔法注释
4042

4143
```vue
4244
<script setup lang="ts">
@@ -48,7 +50,7 @@ defineOptions({
4850
</script>
4951
```
5052

51-
::: details Compiled Code
53+
::: details 编译后代码
5254

5355
```vue
5456
<script lang="ts">

docs/zh-CN/features/named-template.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
# namedTemplate
22

3-
43
<div py2 flex>
5-
<small>Stability: <code class="!text-red-600">experimental</code></small>
6-
<WarnBadge>Experimental, use at your risk</WarnBadge>
4+
<small>稳定性: <code class="!text-red-600">实验性</code></small>
5+
<WarnBadge>实验性功能,风险自负</WarnBadge>
76
</div>
87

8+
通过开启 `namedTemplate``<template>` 可以像变量一样被引用。
99

10-
With enabling `namedTemplate`, `<template>` can be referenced like a variable.
11-
12-
Sometimes we need to reverse the order of the very simple components, and don't want to give the features of Vue template up and use JSX/TSX. Then this feature is much helpful.
10+
有时候我们需要把非常简单的组件颠倒顺序,但又不想放弃 Vue 模板的特性而使用 JSX/TSX。那么这个功能就非常有用了。
1311

14-
If you support this feature, you can go to [the discussion](https://github.com/vuejs/core/discussions/6898) and hit like :+1: or comment.
12+
如果你支持此功能,欢迎在 [讨论](https://github.com/vuejs/core/discussions/6898) 中点赞 :+1: 或评论。
1513

16-
| Features | Supported |
14+
| 特性 | 支持 |
1715
| :----------------: | :----------------: |
1816
| Vue 3 | :white_check_mark: |
1917
| Nuxt 3 | :x: |
2018
| Vue 2 | :x: |
2119
| TypeScript / Volar | :x: |
2220

23-
## Basic Usage
21+
## 基本用法
2422

2523
```vue {5-7,10-12,16-18}
2624
<script setup>
@@ -44,6 +42,6 @@ const pager = 'top'
4442
</template>
4543
```
4644

47-
## Known Usage
45+
## 已知的问题
4846

49-
- TypeScript / Volar support is not yet completed.
47+
- TypeScript / Volar 支持尚未完成。

docs/zh-CN/features/reactivity-transform.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Reactivity Transform
22

3-
<small>Stability: <code class="!text-green-600">stable</code></small>
3+
<small>稳定性: <code class="!text-green-600">稳定</code></small>
44

5-
| Features | Supported |
5+
| 特性 | 支持 |
66
| :----------------: | :----------------: |
77
| Vue 3 | :white_check_mark: |
88
| Nuxt 3 | :white_check_mark: |
99
| Vue 2 | :white_check_mark: |
1010
| TypeScript / Volar | :white_check_mark: |
1111

12-
## Installation Standalone Version
12+
## 安装独立版本
1313

14-
if you need Reactivity Transform feature only, the standalone version is more appropriate for you.
14+
如果你只需要 `Reactivity Transform` 功能,独立版本更适合你。
1515

16-
### Installation
16+
### 安装
1717

1818
::: code-group
1919

@@ -70,7 +70,7 @@ module.exports = {
7070

7171
:::
7272

73-
### TypeScript Support
73+
### TypeScript 支持
7474

7575
```json
7676
// tsconfig.json
@@ -82,6 +82,6 @@ module.exports = {
8282
}
8383
```
8484

85-
## Usage
85+
## 用法
8686

87-
Refer to [official docs](https://vuejs.org/guide/extras/reactivity-transform.html).
87+
参见 [官方文档](https://cn.vuejs.org/guide/extras/reactivity-transform.html).

docs/zh-CN/guide/bundler-integration.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Bundler Integration
1+
# 打包器整合
22

3-
### Installation
3+
### 安装
44

55
::: code-group
66

@@ -96,7 +96,7 @@ module.exports = defineConfig({
9696

9797
:::
9898

99-
## TypeScript Support
99+
## TypeScript 支持
100100

101101
::: code-group
102102

@@ -122,9 +122,9 @@ module.exports = defineConfig({
122122

123123
:::
124124

125-
## Volar Support
125+
## Volar 支持
126126

127-
For detailed configuration, please refer to the description of the specific macro.
127+
有关宏的详细配置请参考每个宏的具体说明。
128128

129129
```bash
130130
npm i -D @vue-macros/volar
@@ -148,6 +148,6 @@ npm i -D @vue-macros/volar
148148
}
149149
```
150150

151-
:tada: Congratulations! You have successfully set up `unplugin-vue-macros`.
151+
:tada: 恭喜你! 目前你已经成功将 `unplugin-vue-macros` 设置完成。
152152

153-
To learn more about the macros, please visit [All Macros](/macros/) :laughing:.
153+
如果你还想要了解有关宏的更多信息, 请访问 [全部宏](/zh-CN/macros/) :laughing:

docs/zh-CN/guide/configurations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Configurations
1+
# 配置
22

3-
## Plugin Options
3+
## 插件选项
44

5-
All features are enabled by default, you can disable them by setting the option to `false`.
5+
在 Vue Macros 中所有功能都将会被默认开启,你可以将选项设置为 `false` 来禁用它们。
66

77
```ts
88
VueMacros({
@@ -37,4 +37,4 @@ VueMacros({
3737
})
3838
```
3939

40-
See the features page for options for each feature.
40+
有关每个宏的配置选项,请参考对应宏的页面。

docs/zh-CN/guide/getting-started.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
# Getting Started
1+
# 入门
22

3-
Vue Macros is a library that implements proposals or ideas that have not been officially implemented by Vue. That means it will explore and extend more features and syntax sugar to Vue.
3+
Vue Macros 是一个库,用于实现尚未被 Vue 正式实现的提案或想法。这意味着它将探索并扩充更多宏和语法糖到 Vue
44

5-
We assume you are already familiar with the basic usages of Vue before you continue.
5+
在继续之前,我们假设你已经熟悉 Vue 的基本用法。
66

7-
## Requirements
7+
## 要求
88

9-
- Vue >= 2.7 or Vue >= 3.0.
10-
- Some features need Vue >= 3.2.25.
11-
- VSCode with [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) extension.
12-
-WebStorm is not supported.
9+
- Vue >= 2.7 Vue >= 3.0
10+
- 某些功能需要 Vue >= 3.2.25
11+
- VSCode 安装了 [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) 扩展
12+
-不支持 WebStorm
1313

14-
## Demos
14+
## 示例
1515

1616
- [Vite + Vue 3](https://github.com/sxzz/unplugin-vue-macros/tree/main/playground/vue3)
1717
- [Vite + Vue 2](https://github.com/sxzz/unplugin-vue-macros/tree/main/playground/vue2)
1818
- [Nuxt 3 + Vue 3](https://github.com/vue-macros/nuxt)
1919
- [Vue CLI + Vue 2](https://github.com/vue-macros/vue2-vue-cli)
2020

21-
🌟 More demos are welcome!
21+
🌟 欢迎提供更多示例!
2222

23-
## Nuxt Integration
23+
## Nuxt 整合
2424

25-
If you're using [Nuxt 3](https://nuxt.com/), read the [Nuxt Integration](./nuxt-integration.md).
25+
如果你使用的是 [Nuxt 3](https://nuxt.com/),请阅读 [Nuxt 整合](./nuxt-integration.md)
2626

27-
## Bundler Integrations
27+
## 打包器整合
2828

29-
If you're using [Vite](https://vitejs.dev/), [Rollup](https://rollupjs.org/), [esbuild](https://esbuild.github.io/), or [Webpack](https://webpack.js.org/), read the [Bundler Integration](./bundler-integration.md).
29+
如果你使用的是 [Vite](https://vitejs.dev/)[Rollup](https://rollupjs.org/)[esbuild](https://esbuild.github.io/),或 [Webpack](https://webpack.js.org/) 这一类的打包器,请阅读 [打包器整合](./bundler-integration.md)

0 commit comments

Comments
 (0)