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

l10n(zh-CN): New translations from Crowdin #2212

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 5 additions & 8 deletions source/zh-cn/api/box.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
title: Box
---

Box is a container used for processing files in a specified folder. 「Box」是 Hexo 用来处理特定文件夹中的文件的容器在 Hexo 中有两个 Box,分别是 `hexo.source``hexo.theme`前者用于处理 `source` 文件夹,而后者用于处理主题文件夹。 The former is used to process the `source` folder and the latter to process the `theme` folder.
Box 是 Hexo 用来处理特定文件夹中的文件的容器在 Hexo 中有两个 Box,分别是 `hexo.source``hexo.theme`前者用于处理 `source` 文件夹,后者用于处理 `theme` 文件夹。

## 加载文件

Box 提供了两种方法来加载文件:`process`, `watch`,前者用于加载文件夹内的所有文件;而后者除了执行 `process` 以外,还会继续监视文件变动`process` loads all files in the folder. `watch` does the same, but also starts watching for file changes.
Box 提供了两种方法来加载文件:`process``watch` `process` 加载文件夹中的所有文件`watch` 做了与前者相同的操作,但还会开始监视文件的更改。

```js
box.process().then(function () {
// ...
box.process().then(function () {
// ...
});

box.watch().then(function () {
// 之后可调用 box.unwatch(),停止监视文件
});
// 之后可调用 box.unwatch(),停止监视文件。
});
```

## 比对路径

Box provides many ways for path matching. Box 提供了多种比对路径的模式您可以以使用正则表达式(regular expression)、函数、或是 Express 风格的模式字符串例如: For example:
Box 提供了多种比对路径的模式您可以以使用正则表达式(regular expression)、函数、或是 Express 风格的模式字符串例如:

```plain
posts/:id => posts/89
Expand All @@ -34,7 +31,7 @@ posts/*path => posts/2015/title

## 处理器(Processor)

处理器(Processor)是 Box 中非常重要的元素,它用于处理文件,您可以使用上述的路径对比来限制该处理器所要处理的文件类型。 You can use path matching as described above to restrict what exactly the processor should process. 使用 `addProcessor` 来添加处理器。
处理器(Processor)是 Box 中非常重要的元素,它用于处理文件。 您可以使用上述的路径对比来限制该处理器所要处理的文件类型。 使用 `addProcessor` 来添加处理器。

```js
box.addProcessor("posts/:id", function (file) {
Expand Down
9 changes: 4 additions & 5 deletions source/zh-cn/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ title: 控制台(Console)
hexo.extend.console.register(name, desc, options, function (args) {
// ...
});
});
```

| Argument | 描述 |
| 参数 | 描述 |
| --------- | -- |
| `name` | 名称 |
| `desc` | 描述 |
Expand All @@ -25,7 +24,7 @@ An argument `args` will be passed into the function. This is the argument that u

### 用法

The usage of a console command. For example:
The usage of a console command. 例如:

```js
{
Expand All @@ -36,7 +35,7 @@ The usage of a console command. For example:

### arguments

控制台各个参数的说明例如: For example:
控制台各个参数的说明例如:

```js
{
Expand All @@ -49,7 +48,7 @@ The usage of a console command. For example:

### options

控制台的各个选项的说明例如: For example:
控制台的各个选项的说明例如:

```js
{
Expand Down
3 changes: 1 addition & 2 deletions source/zh-cn/api/deployer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ title: 部署器(Deployer)
hexo.extend.deployer.register(name, function (args) {
// ...
});
});
```

在函数中会传入 `args` 参数该参数包含了 `_config.yml` 中的 `deploy` 参数值,以及开发者在终端中所传入的参数。 It contains the `deploy` value set in `_config.yml`, as well as the exact input users typed into their terminal.
在函数中会传入 `args` 参数该参数包含了 `_config.yml` 中设置的 `deploy` 值,以及用户在终端中输入的内容。
2 changes: 1 addition & 1 deletion source/zh-cn/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 事件
---

Hexo 继承了 [EventEmitter][]您可以用 `on` 方法监听 Hexo 所发布的事件,也可以使用 `emit` 方法对 Hexo 发布事件更详细的说明请参阅 Node.js 的 API。 Use the `on` method to listen for events emitted by Hexo, and use the `emit` method to emit events. For more information, refer to the Node.js API documentation.
Hexo 继承了 [EventEmitter][]您可以用 `on` 方法监听 Hexo 所发布的事件,也可以使用 `emit` 方法对 Hexo 发布事件更详细的说明请参阅 Node.js 的 API。

### deployBefore

Expand Down
21 changes: 5 additions & 16 deletions source/zh-cn/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ hexo.extend.filter.register(type, function() {
const { config: themeCfg } = this.theme;
if (themeCfg.fancybox) // do something...

}, priority);

// Theme configuration
const { config: themeCfg } = this.theme;
if (themeCfg.fancybox) // do something...

}, priority);
```

You can define the `priority`. Lower `priority` means that it will be executed first. 您可以指定过滤器的优先级 `priority``priority` 值越低,过滤器会越早执行默认的 `priority` 是 10。 我们建议提供配置选项如 `hexo.config.your_plugin.priority`、让用户自行决定过滤器的优先级。
您可以指定过滤器的优先级 `priority``priority` 值越低,过滤器会越早执行默认的 `priority` 是 10。 我们建议提供配置选项如 `hexo.config.your_plugin.priority`、让用户自行决定过滤器的优先级。

## 执行过滤器

Expand All @@ -39,7 +33,7 @@ hexo.extend.filter.execSync(type, data, options);
| `context` | Context |
| `args` | 参数。 必须为数组。 |

`data` 会作为第一个参数传入每个过滤器而您可以在过滤器中通过返回值改变下一个过滤器中的 `data`,如果什么都没有返回的话则会保持原本的 `data`。 The `data` passed into the next filter can be modified by returning a new value. If nothing is returned, the data remains unmodified. 您还可以使用 `args` 指定过滤器的其他参数。 举例来说:
`data` 会作为第一个参数传入每个过滤器而您可以在过滤器中通过返回值改变下一个过滤器中的 `data`。 如果什么都没有返回的话则会保持原本的 data 您还可以使用 `args` 指定过滤器的其他参数。 举例来说:

```js
hexo.extend.filter.register("test", function (data, arg1, arg2) {
Expand Down Expand Up @@ -145,7 +139,6 @@ hexo.extend.filter.register("before_exit", function () {
hexo.extend.filter.register("before_generate", function () {
// ...
});
});
```

### after_generate
Expand All @@ -156,7 +149,6 @@ Executed after generation finishes.
hexo.extend.filter.register("after_generate", function () {
// ...
});
});
```

### template_locals
Expand All @@ -180,7 +172,6 @@ hexo.extend.filter.register("template_locals", function (locals) {
hexo.extend.filter.register("after_init", function () {
// ...
});
});
```

### new_post_path
Expand All @@ -191,7 +182,6 @@ hexo.extend.filter.register("after_init", function () {
hexo.extend.filter.register("new_post_path", function (data, replace) {
// ...
});
});
```

### post_permalink
Expand All @@ -202,20 +192,19 @@ Used to determine the permalink of posts.
hexo.extend.filter.register("post_permalink", function (data) {
// ...
});
});
```

### after_render

Executed after rendering finishes. 在渲染后执行您可以参考 [渲染](rendering.html#after-render-过滤器) 以了解更多信息。
在渲染后执行您可以参考 [渲染](rendering.html#after-render-过滤器) 以了解更多信息。

### after_clean

Executed after generated files and cache are removed with `hexo clean` command.

```js
hexo.extend.filter.register("before_exit", function () {
// ...
hexo.extend.filter.register("after_clean", function () {
// remove some other temporary files
});
```

Expand Down
14 changes: 8 additions & 6 deletions source/zh-cn/api/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ title: 生成器(Generator)
## 概要

```js
hexo.extend.generator.register(name, function (locals) {});
hexo.extend.generator.register(name, function (locals) {
// ...
});
```

`locals` 参数会被传递到此函数,其中包含 [网站变量](../docs/variables.html#网站变量)请尽量利用此参数取得网站数据,避免直接访问数据库。 You should use this argument to get the website data, thereby avoiding having to access the database directly.
`locals` 参数会被传递到此函数,其中包含 [网站变量](../docs/variables.html#网站变量)请尽量利用此参数取得网站数据,避免直接访问数据库。

## 更新路由

Expand All @@ -37,21 +38,21 @@ hexo.extend.generator.register("test", function (locals) {
| `data` | 数据 |
| `layout` | 布局。 Specify the layouts for rendering. The value can be a string or an array. If it's ignored then the route will return `data` directly. |

在原始文件更新时,Hexo 会执行所有生成器并重建路由**请直接回传数据,不要直接操作路由****Please return the data and do not access the router directly.**
在原始文件更新时,Hexo 会执行所有生成器并重建路由**请直接回传数据,不要直接访问路由。**

## 示例

### 归档页面

Create an archive page at `archives/index.html`. We pass all posts as data to the templates. `archives/index.html` 建立一归档页面把所有文章当作数据传入模板内这个数据也就等同于模板中的 `page` 变量。
`archives/index.html` 建立一归档页面把所有文章当作数据传入模板内这个数据也就等同于模板中的 `page` 变量。

Next, set the `layout` attribute to render with the theme templates. We're setting two layouts in this example: if the `archive` layout doesn't exist, the `index` layout will be used instead.

```js
hexo.extend.generator.register("archive", function (locals) {
return {
path: "archives/index.html",
data: locals.posts,
data: locals,
layout: ["archive", "index"],
};
});
Expand All @@ -65,7 +66,8 @@ hexo.extend.generator.register("archive", function (locals) {
var pagination = require("hexo-pagination");

hexo.extend.generator.register("archive", function (locals) {
return pagination("archives/index.html", locals.posts, {
// hexo-pagination makes an index.html for the /archives route
return pagination("archives", locals.posts, {
perPage: 10,
layout: ["archive", "index"],
data: {},
Expand Down
5 changes: 2 additions & 3 deletions source/zh-cn/api/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 辅助函数(Helper)
---

辅助函数帮助您在模板中快速插入内容,建议您把复杂的代码放在辅助函数而非模板中。 We recommend using helpers instead of templates when you're dealing with more complicated code.
辅助函数帮助您在模板中快速插入内容。 建议您把复杂的代码放在辅助函数而非模板中。

辅助函数不能从 `source` 的文件中访问。

Expand All @@ -12,7 +12,6 @@ title: 辅助函数(Helper)
hexo.extend.helper.register(name, function () {
// ...
});
});
```

## 示例
Expand Down Expand Up @@ -44,7 +43,7 @@ hexo.extend.helper.register("lorem", function (path) {
});
```

### 如何在其他插件中使用已经注册的 helper
### 如何在另一个扩展(例如过滤器、注入器)中使用注册的helper

`hexo.extend.helper.get` 会返回一个指定名字的 helper,但是你还需要一个 `bind(hexo)`,就像这样:

Expand Down
11 changes: 3 additions & 8 deletions source/zh-cn/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: API

## 初始化

First, we have to create a Hexo instance. 首先,我们必须建立一个 Hexo 实例(instance),第一个参数是网站的根目录,也就是 `base_dir`而第二个参数则是初始化的选项。 接着执行 `init` 方法后,Hexo 会加载插件及配置文件。
首先,我们必须建立一个 Hexo 实例(instance)。 一个新的实例需要两个参数:网站根目录 `base_dir`以及包含初始化选项的对象。 接着执行 `init` 方法后,Hexo 会加载插件及配置文件。

```js
var Hexo = require("hexo");
Expand All @@ -17,10 +17,9 @@ var hexo = new Hexo(process.cwd(), {});
hexo.init().then(function () {
// ...
});
});
```

| Option | 描述 | 默认值 |
| 选项 | 描述 | 默认值 |
| ------------------ | --------------------------------------------------------------- | ----------------------------------- |
| `debug` | 开启调试模式。 在终端中显示调试信息,并在根目录中存储 `debug.log` 日志文件。 | `false` |
| `safe` | 开启安全模式。 不加载任何插件。 | `false` |
Expand All @@ -30,21 +29,18 @@ hexo.init().then(function () {

## 加载文件

Hexo 提供了两种方法来加载文件:`load`, `watch`,前者用于加载 `source` 文件夹内的所有文件及主题资源;而后者除了执行 `load` 以外,还会继续监视文件变动`load` is used for loading all files in the `source` folder as well as the theme data. `watch` does the same things `load` does, but will also start watching for file changes continuously.
Hexo 提供了两种方法来加载文件:`load``watch``load` 用于加载 `source` 文件夹中的所有文件以及主题数据。 `watch` 执行与 `load` 相同的操作,但还会开始连续监视文件更改。

Both methods will load the list of files and pass them to the corresponding processors. After all files have been processed, they will call upon the generators to create the routes.

```js
hexo.load().then(function () {
// ...
hexo.load().then(function () {
// ...
});

hexo.watch().then(function () {
// 之后可以调用 hexo.unwatch(),停止监视文件
});
});
```

## 执行指令
Expand All @@ -55,7 +51,6 @@ Any console command can be called explicitly using the `call` method on the Hexo
hexo.call("generate", {}).then(function () {
// ...
});
});
```

```js
Expand Down
2 changes: 1 addition & 1 deletion source/zh-cn/api/injector.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ hexo.extend.injector.register("body_end", () => {
});
```

上述代码将会把 `APlayer.min.css``<link>` 标签)和 `APlayer.min.js``<script>` 标签)注入到所有 layout 为 `music` 的页面的 `</head>``</body>` 之前,以及将 `jquery.js``<script>` 标签)注入到每一个生成的页面的 `</body>` 之前。 Also, `jquery.js` (`<script>` tag) will be injected to `</body>` of every page generated.
上述代码将会把 `APlayer.min.css``<link>` 标签)和 `APlayer.min.js``<script>` 标签)注入到所有 layout 为 `music` 的页面的 `</head>``</body>` 之前。 此外,`jquery.js``<script>` tag)将会被注入到生成的每个页面的 `</body>` 之前。

## 访问用户配置

Expand Down
1 change: 0 additions & 1 deletion source/zh-cn/api/locals.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ hexo.locals.get("posts");
hexo.locals.set('posts', function(){
return ...
});
});
```

## 移除变量
Expand Down
3 changes: 1 addition & 2 deletions source/zh-cn/api/migrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ title: Migrator
hexo.extend.migrator.register(name, function (args) {
// ...
});
});
```

在函数中需要传入 `args` 参数,该参数包含了开发者在终端中所传入的参数。 This argument will contain the user's input into the terminal.
在函数中需要传入 `args` 参数。 该参数包含了开发者在终端中所传入的参数。
8 changes: 4 additions & 4 deletions source/zh-cn/api/posts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
title: 文章
---

## Create a Post
## 创建一个文章

```js
hexo.post.create(data, replace);
```

| Argument | 描述 |
| 参数 | 描述 |
| --------- | ------ |
| `data` | 数据 |
| `replace` | 替换现有文件 |
Expand All @@ -29,7 +29,7 @@ The attributes of a post can be defined in `data`. The table below is not exhaus
hexo.post.publish(data, replace);
```

| Argument | 描述 |
| 参数 | 描述 |
| --------- | ------ |
| `data` | 数据 |
| `replace` | 替换现有文件 |
Expand All @@ -47,7 +47,7 @@ The attributes of a post can be defined in `data`. The table below is not exhaus
hexo.post.render(source, data);
```

| Argument | 描述 |
| 参数 | 描述 |
| -------- | ------------ |
| `source` | 文件的完整路径(可忽略) |
| `data` | 数据 |
Expand Down
3 changes: 2 additions & 1 deletion source/zh-cn/api/processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ title: 处理器(Processor)
## 概要

```js
hexo.extend.processor.register(rule, function (file) {});
hexo.extend.processor.register(rule, function (file) {
// ...
});
```

Expand Down
Loading