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-TW): New translations from Crowdin #2209

Merged
merged 1 commit into from
Jul 5, 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
41 changes: 22 additions & 19 deletions source/zh-tw/api/box.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,64 @@
title: 箱子(Box)
---

「箱子」是 Hexo 用來處理特定資料夾中的檔案的容器,在 Hexo 中有兩個箱子,分別是 `hexo.source` 和 `hexo.theme`,前者用於處理 `source` 資料夾,而後者用於處理主題資料夾。
Box is a container used for processing files in a specified folder. 「箱子」是 Hexo 用來處理特定資料夾中的檔案的容器,在 Hexo 中有兩個箱子,分別是 `hexo.source` 和 `hexo.theme`,前者用於處理 `source` 資料夾,而後者用於處理主題資料夾。 The former is used to process the `source` folder and the latter to process the `theme` folder.

## 載入檔案

箱子提供了兩種方法來載入檔案:`process`, `watch`,前者用於載入資料夾內的所有檔案;而後者除了執行 `process` 以外,還會繼續監看檔案變動。
箱子提供了兩種方法來載入檔案:`process`, `watch`,前者用於載入資料夾內的所有檔案;而後者除了執行 `process` 以外,還會繼續監看檔案變動。 `process` loads all files in the folder. `watch` does the same, but also starts watching for file changes.

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

box.watch().then(function () {
// 之後可呼叫 box.unwatch() 停止檔案監看
});
});
```

## 路徑比對

箱子提供了多種路徑比對的模式,您可使用正規表達式(regular expression)、函數、或是一種類似於 Express 的路徑字串,例如:
Box provides many ways for path matching. You can use a regular expression, a function or an Express-style pattern string. For example:

```plain
posts/:id => posts/89
posts/*path => posts/2015/title
```

您可參考 [util.Pattern] 以獲得更多資訊。
您可參考 [util.Pattern][] 以獲得更多資訊。

## 處理器(Processor)

處理器(Processor)是箱子中非常重要的元素,它用於處理檔案,您可使用上述的路徑比對來限制該處理器所要處理的檔案類型。使用 `addProcessor` 來註冊處理器。
處理器(Processor)是箱子中非常重要的元素,它用於處理檔案,您可使用上述的路徑比對來限制該處理器所要處理的檔案類型。 You can use path matching as described above to restrict what exactly the processor should process. 使用 `addProcessor` 來註冊處理器。

```js
box.addProcessor("posts/:id", function (file) {
//
});
```

箱子在處理時會把目前處理的檔案內容(`file`)傳給處理器,您可透過此參數取得該檔案的資訊。
Box passes the content of matched files to processors. This information can then be read straight from the `file` argument in the callback:

| 屬性 | 描述 |
| -------- | --------------------------------------------------- |
| 屬性 | 描述 |
| -------- | --------------------------------------------- |
| `source` | 檔案完整路徑 |
| `path` | 檔案相對於箱子的路徑 |
| `type` | 檔案類型。有 `create`, `update`, `skip`, `delete`。 |
| `params` | 從路徑比對中取得的資訊 |
| `path` | 檔案相對於箱子的路徑 |
| `type` | 檔案類型。 有 `create`, `update`, `skip`, `delete`。 |
| `params` | The information from path matching. |

箱子還提供了一些方法,讓您無須自行處理檔案 IO。

| 方法 | 描述 |
| ------------ | ---------------- |
| `read` | 讀取檔案 |
| `readSync` | 同步讀取檔案 |
| `stat` | 讀取檔案狀態 |
| `statSync` | 同步讀取檔案狀態 |
| `render` | 渲染檔案 |
| `renderSync` | 同步渲染檔案 |
| 方法 | 描述 |
| ------------ | ------------------------- |
| `read` | 讀取檔案 |
| `readSync` | 同步讀取檔案 |
| `stat` | Read the status of a file |
| `statSync` | 同步讀取檔案狀態 |
| `render` | 渲染檔案 |
| `renderSync` | 同步渲染檔案 |

[util.Pattern]: https://github.com/hexojs/hexo-util#patternrule
23 changes: 12 additions & 11 deletions source/zh-tw/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
title: 控制台(Console)
---

控制台是 Hexo 與使用者之間溝通的橋樑。
控制台是 Hexo 與使用者之間溝通的橋樑。 It registers and describes the available console commands.

## 概要

```js
hexo.extend.console.register(name, desc, options, function (args) {
// ...
});
});
```

| 參數 | 描述 |
| --------- | ---- |
| Argument | 描述 |
| --------- | -- |
| `name` | 名稱 |
| `desc` | 描述 |
| `options` | 選項 |

在函數中會傳入 `args` 參數,此參數是使用者在終端機所傳入的參數,是一個經 [Minimist] 解析的物件。
An argument `args` will be passed into the function. This is the argument that users type into the terminal. It's parsed by [Minimist][].

## 選項

### 用法

控制台的操作方法,例如:
The usage of a console command. For example:

```js
{
Expand All @@ -33,9 +34,9 @@ hexo.extend.console.register(name, desc, options, function (args) {
// hexo new [layout] <title>
```

### 參數
### arguments

控制台各個參數的說明,例如:
The description of each argument of a console command. For example:

```js
{
Expand All @@ -46,19 +47,19 @@ hexo.extend.console.register(name, desc, options, function (args) {
}
```

### 選項
### options

控制台的選項,例如:
The description of each option of a console command. For example:

```js
{
options: [{ name: "-r, --replace", desc: "Replace existing files" }];
}
```

### 描述
### desc

控制台更詳細的說明。
More detailed information about a console command.

## 範例

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

在函數中會傳入 `args` 參數,此參數包含了 `_config.yml` 中的 `deploy` 設定,及使用者在終端機所傳入的參數。
An argument `args` will be passed into the function. 在函數中會傳入 `args` 參數,此參數包含了 `_config.yml` 中的 `deploy` 設定,及使用者在終端機所傳入的參數。
28 changes: 14 additions & 14 deletions source/zh-tw/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,53 @@
title: 事件
---

Hexo 繼承了 [EventEmitter],您可用 `on` 方法監聽 Hexo 所發佈的事件,亦可用 `emit` 方法對 Hexo 發佈事件,更詳細的說明請參閱 Node.js 的 API。
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.

### deployBefore

在佈署工作執行前發佈。
Emitted before deployment begins.

### deployAfter

在佈署工作執行成功後發佈。
Emitted after deployment finishes.

### exit

Hexo 結束前發佈。
Emitted before Hexo exits.

### generateBefore

在產生靜態檔案前發佈。
Emitted before generation begins.

### generateAfter

在靜態檔案產生完成後發佈。
Emitted after generation finishes.

### new

在文章檔案建立完成後發佈。此事件會回傳資料參數。
Emitted after a new post has been created. This event returns the post data:

```js
hexo.on("new", function (post) {
//
});
```

| 資料 | 描述 |
| -------------- | ------------------ |
| `post.path` | 文章檔案的完整路徑 |
| `post.content` | 文章檔案的內容 |
| 資料 | 描述 |
| -------------- | ------------------------ |
| `post.path` | 文章檔案的完整路徑 |
| `post.content` | Content of the post file |

### processBefore

在處理原始檔案前發佈。此事件會回傳一個路徑,代表箱子(Box)的根目錄。
Emitted before processing begins. 此事件會回傳一個路徑,代表箱子(Box)的根目錄。

### processAfter

在原始檔案處理完成後發佈。此事件會回傳一個路徑,代表箱子(Box)的根目錄。
Emitted after processing finishes. 此事件會回傳一個路徑,代表箱子(Box)的根目錄。

### ready

在初始化完成後發佈。
Emitted after initialization finishes.

[EventEmitter]: https://nodejs.org/dist/latest/docs/api/events.html
51 changes: 36 additions & 15 deletions source/zh-tw/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 過濾器(Filter)
---

過濾器用於修改特定資料,Hexo 將資料依序傳給過濾器,而過濾器可以針對資料進行修改,這個概念是從 [WordPress](http://codex.wordpress.org/Plugin_API#Filters) 借來的。
A filter is used to modify some specified data. Hexo passes data to filters in sequence and the filters then modify the data one after the other. This concept was borrowed from [WordPress](http://codex.wordpress.org/Plugin_API#Filters).

## 概要

Expand All @@ -16,10 +16,16 @@ 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);
```

您可指定過濾器的優先度 `priority`,`priority` 值越低的過濾器會越先執行,預設的 `priority` 是 10。
You can define the `priority`. Lower `priority` means that it will be executed first. 您可指定過濾器的優先度 `priority`,`priority` 值越低的過濾器會越先執行,預設的 `priority` 是 10。 We recommend using user-configurable priority value that user can specify in the config, e.g. `hexo.config.your_plugin.priority`.

## 執行過濾器

Expand All @@ -28,12 +34,12 @@ hexo.extend.filter.exec(type, data, options);
hexo.extend.filter.execSync(type, data, options);
```

| 選項 | 描述 |
| --------- | ------------------ |
| `context` | Context |
| `args` | 參數。必須為陣列。 |
| 選項 | 描述 |
| --------- | --------------------------------- |
| `context` | Context |
| `args` | Arguments. This must be an array. |

`data` 會作為第一個參數傳入每個過濾器,而您可在過濾器中透過回傳值改變下一個過濾器中的 `data`,如果什麼都沒回傳的話則會保持原本的 `data`。您還可使用 `args` 指定過濾器的其他參數。舉例來說:
The first argument passed into each filter is `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` 指定過濾器的其他參數。 舉例來說:

```js
hexo.extend.filter.register("test", function (data, arg1, arg2) {
Expand Down Expand Up @@ -94,9 +100,9 @@ hexo.extend.filter.unregister("example", require("path/to/filter"));

### before_post_render

在文章開始渲染前執行。您可參考 [文章渲染](posts.html#渲染) 以瞭解執行順序。
在文章開始渲染前執行。 您可參考 [文章渲染](posts.html#渲染) 以瞭解執行順序。

舉例來說,把標題轉為小寫:
For example, to transform the title to lower case:

```js
hexo.extend.filter.register("before_post_render", function (data) {
Expand All @@ -107,7 +113,7 @@ hexo.extend.filter.register("before_post_render", function (data) {

### after_post_render

在文章渲染完成後執行。您可參考 [文章渲染](posts.html#渲染) 以瞭解執行順序。
在文章渲染完成後執行。 您可參考 [文章渲染](posts.html#渲染) 以瞭解執行順序。

舉例來說,把 `@username` 取代為 Twitter 的使用者連結。

Expand Down Expand Up @@ -139,16 +145,18 @@ hexo.extend.filter.register("before_exit", function () {
hexo.extend.filter.register("before_generate", function () {
// ...
});
});
```

### after_generate

在產生器執行結束後執行。
Executed after generation finishes.

```js
hexo.extend.filter.register("after_generate", function () {
// ...
});
});
```

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

### new_post_path

用來決定新建文章的路徑,在建立文章時執行。
Executed when creating a post to determine the path of new posts.

```js
hexo.extend.filter.register("new_post_path", function (data, replace) {
// ...
});
});
```

### post_permalink

用來決定文章的永久連結。
Used to determine the permalink of posts.

```js
hexo.extend.filter.register("post_permalink", function (data) {
// ...
});
});
```

### after_render

在渲染後執行,您可參考 [渲染](rendering.html#after_render_過濾器) 以瞭解更多資訊。
Executed after rendering finishes. 在渲染後執行,您可參考 [渲染](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 () {
// ...
});
```

### server_middleware

新增伺服器的 Middleware。`app` 是一個 [Connect] 實例。
新增伺服器的 Middleware。 `app` 是一個 [Connect][] 實例。

舉例來說,在回應標頭中新增 `X-Powered-By: Hexo`。

Expand Down
Loading