Skip to content

Commit 36610a5

Browse files
committed
docs: translation
1 parent 10e2906 commit 36610a5

File tree

3 files changed

+51
-57
lines changed

3 files changed

+51
-57
lines changed

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ zhlint --case-ignore <filepath>
5959
zhlint --dir <path>
6060
```
6161

62-
In the config file, you can write a JSON like:
62+
In the rc config file, you can write a JSON like:
6363

6464
```json
6565
{
6666
"preset": "default",
6767
"rules": {
68-
"adjustedFullWidthPunctuation": ""
68+
"adjustedFullwidthPunctuation": ""
6969
}
7070
}
7171
```
@@ -144,7 +144,7 @@ You could find a JavaScript file `dist/zhlint.js` as a standalone version. To us
144144

145145
## API
146146

147-
- `run(str: string, options?: Options): Result`: Lint a certain file.
147+
- `run(str: string, options?: Options): Result`: Lint a certain content.
148148
- parameters:
149149
- `str`: The text content you want to lint.
150150
- `options`: Some options to config.
@@ -154,8 +154,8 @@ You could find a JavaScript file `dist/zhlint.js` as a standalone version. To us
154154
- parameters:
155155
- `results`: An array for all linted results.
156156
- `logger`: The logger instance, by default it's `console` in Node.js/browser.
157-
- `readRc: (dir: string, config: string, ignore: string, logger?: Console) => Config`: Read config from rc file(s). For rc (run command).
158-
- `runWithConfig(str: string, config: Config): Result`: Lint a certain file with rc config. For rc (run command).
157+
- `readRc: (dir: string, config: string, fileIgnore: string, caseIgnore: string, logger?: Console) => Config`: Read config from rc & ignore file(s).
158+
- `runWithConfig(str: string, config: Config): Result`: Lint a certain content with rc config.
159159

160160
### Options
161161

@@ -216,8 +216,6 @@ type Validation = {
216216
- `length`: The length of the target token in the input string.
217217
- `message`: The description of this validation in natural language.
218218
219-
### Advanced usage
220-
221219
## Features
222220
223221
### Markdown syntax support

README.zh-CN.md

+41-43
Original file line numberDiff line numberDiff line change
@@ -40,47 +40,47 @@ zhlint --help
4040

4141
![](./docs/screenshot-cli.png)
4242

43-
#### Advanced usage
43+
#### 高阶用法
4444

45-
zhlint also supports rc and ignore config files for custom rules:
45+
zhlint 还支持 rc ignore 配置文件:
4646

4747
```bash
48-
# .zhlintrc by default
48+
# 默认为 .zhlintrc
4949
zhlint --config <filepath>
5050

51-
# .zhlintignore by default
51+
# 默认为 .zhlintignore
5252
zhlint --ignore <filepath>
5353
zhlint --file-ignore <filepath>
5454

55-
# .zhlintcaseignore by default
55+
# 默认为 .zhlintcaseignore
5656
zhlint --case-ignore <filepath>
5757

58-
# current directory by default
58+
# 默认为 current directory
5959
zhlint --dir <path>
6060
```
6161

62-
In the config file, you can write a JSON like:
62+
在 rc 配置文件中,您可以写一个 JSON,例如:
6363

6464
```json
6565
{
6666
"preset": "default",
6767
"rules": {
68-
"adjustedFullWidthPunctuation": ""
68+
"adjustedFullwidthPunctuation": ""
6969
}
7070
}
7171
```
7272

73-
For more details, see [supported rules](#supported-rules).
73+
关于更多细节,请参见[支持的规则](#支持的规则)
7474

75-
In the file-ignore file, you can write some lines to ignore files in [.gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format):
75+
file-ignore 文件中,您可以写多行内容来忽略相应的文件,其语法遵循 [.gitignore 语法](https://git-scm.com/docs/gitignore#_pattern_format)
7676

77-
In the case-ignore file, you can write some lines of ignored cases like:
77+
case-ignore 文件中,您可以写多行内容来忽略一些特例,例如:
7878

7979
```txt
8080
( , )
8181
```
8282

83-
For more details, see [setup ignored cases](#setup-ignored-cases).
83+
关于更多细节:请参见[设置被忽略的特例](#设置被忽略的特例)
8484

8585
### 作为 Node.js 包
8686

@@ -116,24 +116,24 @@ Invalid files:
116116
Found 2 errors.
117117
```
118118

119-
#### Advanced usage
119+
#### 高阶用法
120120

121-
zhlint also supports rc and ignore config files for custom rules:
121+
zhlint 还支持 rc ignore 配置文件:
122122

123123
```js
124124
const { readRc, runWithConfig } = require('zhlint')
125125

126126
const value = '自动在中文和English之间加入空格'
127127

128-
const dir = '...' // the target directory path
129-
const configPath = '...' // the config file path
130-
const fileIgnorePath = '...' // the file-ignore file path
131-
const caseIgnorePath = '...' // the case-ignore file path
128+
const dir = '...' // 目标文件所在的目录
129+
const configPath = '...' // rc 配置文件路径
130+
const fileIgnorePath = '...' // file-ignore 文件路径
131+
const caseIgnorePath = '...' // case-ignore 文件路径
132132

133133
const config = readRc(dir, configPath, fileIgnorePath, caseIgnorePath)
134134
const output = runWithConfig(value, config)
135135

136-
// ... further actions
136+
// ... 后续操作
137137
```
138138

139139
### 作为一个单独的包
@@ -144,18 +144,18 @@ const output = runWithConfig(value, config)
144144

145145
## API
146146

147-
- `run(str: string, options?: Options): Result`格式化某个文件
147+
- `run(str: string, options?: Options): Result`格式化某个文件内容
148148
- 参数:
149149
- `str`:需要格式化的文本内容。
150150
- `options`:一些配置选项。
151151
- 返回值:
152-
- 针对输入的单个字符串的处理结果。其包好了修复格式之后的文本内容 `value` 以及所有 `validation` 的校验信息
153-
- `report(results: Result[], logger?: Console): void`为每个文件打印校验报告
152+
- 针对输入的单个字符串的处理结果。其包好了修复格式之后的文本内容 `value` 以及所有 `validation` 的格式化信息
153+
- `report(results: Result[], logger?: Console): void`为每个文件打印格式化报告
154154
- 参数:
155155
- `results`:所有格式化结果的数组。
156156
- `logger`:日志处理器实例,默认是 Node.js/浏览器中的 `console`
157-
- `readRc: (dir: string, config: string, ignore: string, logger?: Console) => Config`: Read config from rc file(s). For rc (run command).
158-
- `runWithConfig(str: string, config: Config): Result`: Lint a certain file with rc config. For rc (run command).
157+
- `readRc: (dir: string, config: string, fileIgnore: string, caseIgnore: string, logger?: Console) => Config`:读取配置文件信息。
158+
- `runWithConfig(str: string, config: Config): Result`:通过配置信息格式化特定内容。
159159

160160
### 选项
161161

@@ -179,23 +179,23 @@ type Options = {
179179
180180
### RC Config
181181
182-
- `preset`: `string` (optional)
183-
- `rules`: `RuleOptions` without the `preset` field. (optional)
184-
- `hyperParsers`: `string[]` (optional)
185-
- `caseIgnores`: `string[]` and the priority is lower than `.zhlintcaseignore`. (optional)
182+
- `preset`: `string` (可选项)
183+
- `rules`: `RuleOptions` 但不包括 `preset` 字段。(可选项)
184+
- `hyperParsers`: `string[]` (可选项)
185+
- `caseIgnores`: `string[]` 该优先级低于 `.zhlintcaseignore`。(可选项)
186186
187187
### 输出格式
188188
189189
```ts
190190
type Result = {
191-
// the basic info and availability of the file
191+
// 基本信息和文件的可用性
192192
file?: string
193193
disabled: boolean
194194

195-
// the original content of the file
195+
// 原始的文本内容
196196
origin: string
197197

198-
// all the error messages
198+
// 所有错误信息
199199
validations: Validation[]
200200
}
201201

@@ -210,39 +210,37 @@ type Validation = {
210210
- `file`:文件名。这是一个可选的字段,只在 CLI 中适用。
211211
- `origin`:原始的文本内容。
212212
- `result`:最终修复格式的文本内容。
213-
- `validations`所有校验信息
213+
- `validations`所有格式化信息
214214
- `Validation`
215215
- `index`:输入的字符串中目标片段所在的索引值。
216216
- `length`:输入的字符串中目标片段的长度。
217-
- `message`:对该校验信息的自然语言描述。
218-
219-
### Advanced usage
217+
- `message`:对该格式化信息的自然语言描述。
220218
221219
## 特性
222220
223221
### Markdown 语法支持
224222
225-
We support lint your text content in Markdown syntax by default. For example:
223+
我们默认支持格式化 Markdown 语法的文本内容。例如:
226224
227225
```js
228226
run('自动在_中文_和**English**之间加入空格')
229227
```
230228
231-
It will analyse the Markdown syntax first and extract the pure text content and do the lint job. After that the fixed pure text content could be replaced back to the raw Markdown string and returned as the output `value` in result.
229+
这将首先分析 Markdown 语法并提取纯文本内容,然后执行格式化操作。修复后的纯文本内容可以复原为 Markdown 格式字符串,并作为结果中的输出 `value` 返回。
232230
233231
### [Hexo tag](https://hexo.io/docs/tag-plugins) 语法支持
234232
235-
Specially, we support [Hexo tags syntax](https://hexo.io/docs/tag-plugins) just because when we use Hexo to build Vue.js website, the markdown source files more or less include special tags like that so got the unpredictable result.
233+
特别地,我们支持 [Hexo tag 语法](https://hexo.io/docs/tag-plugins)。这是因为当我们使用 Hexo 构建 Vue.js 网站时,Markdown 源文件中可能包含一些特殊的标签从而得到不可预测的格式化结果。
236234
237-
As a result, we additionally skip the Hexo-style tags by default. For example:
235+
因此,我们会默认跳过 Hexo 风格的标签。例如:
238236
239237
```js
240238
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。')
241239
```
242240
243241
### 设置被忽略的特例
244242
245-
In some real cases we have special text contents not follow the rules by reason. So we could ues `ignoredCases` option to config that. For example we'd like to keep the spaces inside a pair of brackets, which is invalid by default. Then we could write one more line of HTML comment anywhere inside the file:
243+
在一些特殊的情况下,我们可能会有一些特殊的文本内容不遵循规则。因此,我们可以使用 `ignoredCases` 选项来配置。例如,我们想要保留括号内的空格,这在默认情况下是格式不正确的。不过我们可以在文件的任何地方写一行 HTML 注释:
246244
247245
```md
248246
<!-- the good case -->
@@ -263,7 +261,7 @@ vm.$on( event, callback )
263261
run(str, { ignoredCases: { textStart: '( ', textEnd: ' )' } })
264262
```
265263

266-
If you want to ignore the whole file, you can also add this HTML comment:
264+
如果你想要忽略整个文件,你也可以添加这个 HTML 注释:
267265

268266
```md
269267
<!-- zhlint disabled -->
@@ -472,6 +470,6 @@ type RuleOptions = {
472470
}
473471
````
474472

475-
## More information
473+
## 更多信息
476474

477-
zhlint is now open sourced on [GitHub](https://github.com/zhlint-project/zhlint) and [issues](https://github.com/zhlint-project/zhlint/issues) welcome.
475+
zhlint 是一个开源项目,目前源代码在 [GitHub](https://github.com/zhlint-project/zhlint) 上,也欢迎大家来提交 [issue](https://github.com/zhlint-project/zhlint/issues)

docs/index.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ zhlint --case-ignore <filepath>
6565
zhlint --dir <path>
6666
```
6767

68-
In the config file, you can write a JSON like:
68+
In the rc config file, you can write a JSON like:
6969

7070
```json
7171
{
7272
"preset": "default",
7373
"rules": {
74-
"adjustedFullWidthPunctuation": ""
74+
"adjustedFullwidthPunctuation": ""
7575
}
7676
}
7777
```
@@ -156,7 +156,7 @@ You could find a JavaScript file `dist/zhlint.js` as a standalone version. To us
156156

157157
## API
158158

159-
- `run(str: string, options?: Options): Result`: Lint a certain file.
159+
- `run(str: string, options?: Options): Result`: Lint a certain content.
160160
- parameters:
161161
- `str`: The text content you want to lint.
162162
- `options`: Some options to config.
@@ -166,8 +166,8 @@ You could find a JavaScript file `dist/zhlint.js` as a standalone version. To us
166166
- parameters:
167167
- `results`: An array for all linted results.
168168
- `logger`: The logger instance, by default it's `console` in Node.js/browser.
169-
- `readRc: (dir: string, config: string, ignore: string, logger?: Console) => Config`: Read config from rc file(s). For rc (run command).
170-
- `runWithConfig(str: string, config: Config): Result`: Lint a certain file with rc config. For rc (run command).
169+
- `readRc: (dir: string, config: string, fileIgnore: string, caseIgnore: string, logger?: Console) => Config`: Read config from rc & ignore file(s).
170+
- `runWithConfig(str: string, config: Config): Result`: Lint a certain content with rc config.
171171

172172
### Options
173173

@@ -228,8 +228,6 @@ type Validation = {
228228
- `length`: The length of the target token in the input string.
229229
- `message`: The description of this validation in natural language.
230230
231-
### Advanced usage
232-
233231
## Features
234232
235233
### Markdown syntax support

0 commit comments

Comments
 (0)