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

Translate eloquent-resources.md (v5.5) #384

Merged

Conversation

Nationalcat
Copy link
Collaborator

Translate eloquent-resources.md (v5.5)

  1. 大部分的 resources 都沒翻,但有點想翻
  2. 關於 meta- 的翻譯則是參照 google 找到的用法,像是 meta data,會是資料的資料。
  3. 原文有很多句子都捨不得用標點符號分開,然後各種連接詞和介系詞,所以容易翻錯....

- [Conditional Relationships](#conditional-relationships)
- [Adding Meta Data](#adding-meta-data)
- [Resource Responses](#resource-responses)
# Eloquent: API 資源
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eloquent:API 資源

# Eloquent: API 資源

- [介紹](#introduction)
- [產生 Resouce](#generating-resources)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

產生資源

- [有條件的屬性](#conditional-attributes)
- [有條件的關聯](#conditional-relationships)
- [新增資料的資料](#adding-meta-data)
- [Resouce 回應](#resource-responses)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

資源回應


When building an API, you may need a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON.
當你在建構 API 時,可能會需要一個位於 Eloquent 模型和實際回傳給使用者的 JSON 回應之間的轉換層。Laravel 的 Resouce 類別可以讓你更直觀且容易的將你的模型和模型集合轉換成 JSON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

當你在建立一個 API 時,可能會需要一個位於 Eloquent 模型和實際回傳給使用者的 JSON 回應之間的轉換層。Laravel 的資源類別可以讓你更直觀且容易的將你的模型和模型集合轉換成 JSON。


To generate a resource class, you may use the `make:resource` Artisan command. By default, resources will be placed in the `app/Http/Resources` directory of your application. Resources extend the `Illuminate\Http\Resources\Json\Resource` class:
你可以使用 Artisan 的 `make:resource` 指令來產生一個 Resouce 類別。預設的 Resouce 會放置於 `app/Http/Resources` 你的應用程式目錄中。Resources 會繼承 `Illuminate\Http\Resources\Json\Resource` 類別:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 「Resource」都翻譯成「資源」
  • 預設的 Resouce 會放置於你的 app/Http/Resources 應用程式目錄中。

@@ -569,19 +569,19 @@ Sometimes you may wish to only include certain meta data with a resource respons
}
}

#### Adding Meta Data When Constructing Resources
#### 在建構資源時新增資料的資料
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在建構資源時新增 Meta Data 的資料


You may also add top-level data when constructing resource instances in your route or controller. The `additional` method, which is available on all resources, accepts an array of data that should be added to the resource response:
在你的路由或控制器建構 Resource 實例時,你也可以新增最上層的資料。`additional` 方法在所有的 Resource 都可以用,並接受應該被新增到 Resource 回應的資料陣列:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「Resource」都翻譯成「資源」


As you have already read, resources may be returned directly from routes and controllers:
正如你已讀過的,Resource 可以從路由或控制器中回傳:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「Resource」都翻譯成「資源」

@@ -601,7 +601,7 @@ However, sometimes you may need to customize the outgoing HTTP response before i
->header('X-Value', 'True');
});

Alternatively, you may define a `withResponse` method within the resource itself. This method will be called when the resource is returned as the outer-most resource in a response:
或者是你可以在 Resource 中定義 `withResponse` 方法。這個方法會在 Resource 作為回應中的最外層時被呼叫:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「Resource」都翻譯成「資源」

- [分頁](#pagination)
- [有條件的屬性](#conditional-attributes)
- [有條件的關聯](#conditional-relationships)
- [新增資料的資料](#adding-meta-data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增 Meta Data

@neighborhood999 neighborhood999 merged commit 428219a into laravel-taiwan:5.5 Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants