Skip to content
Merged
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
98 changes: 44 additions & 54 deletions glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,90 +6,80 @@ title: 用語集

## コントローラー

[Model-View-Controller][MVC] はソフトウエア開発の標準的な開発手法です。もしあなたがまだ詳しくないのなら、さらっと読んでおくと理解が早まるでしょう
[Model-View-Controller][MVC] はソフトウエア開発の標準的な開発手法です。もしあなたがまだ詳しくないのなら、少し勉強しておくとすると先に進むのが速くなると思います

WP-APIでは、エンドポイントで使用されるクラスの設計で、このコントローラーの考え方を踏襲しており、すべてのエンドポイントは `WP_REST_Controller` クラスを継承し、共通メソッドの信頼性を確保しています。

[MVC]: http://ja.wikipedia.org/wiki/Model-view-controller

## HEAD, GET, POST, PUT, そして DELETE リクエスト

These "HTTP verbs" represent the _type_ of action a HTTP client might perform
against a resource. For instance, `GET` requests are used to fetch a Post's
data, whereas `DELETE` requests are used to delete a Post. They're
collectively called "HTTP verbs" because they're standardized across the web.
これらの “HTTP verbs (http 動詞)” は、HTTPクライアントが、リソースに対して実行しようとするアクションのタイプを表しています。
たとえば、 `GET` リクエストは投稿のデータを取得するために使われ、 `DELETE` リクエストは投稿を削除するために使われる、というように。
これらの語はまとめて HTTP verbs と呼ばれており、それは web に置いて標準化されたものです。

If you're familiar with WordPress functions, a `GET` request is the equivalent
of `wp_remote_get()`, and a `POST` request is the same as `wp_remote_post()`.
WordPress の関数に慣れ親しんでいる人であれば、 `GET` は `wp_remote_get()` に、`POST` は `wp_remote_post()` に対応すると言えます。

## HTTP Client
## HTTP クライアント

The phrase "HTTP Client" refers to the tool you use to interact with WP-API.
You might use [Postman][] (Chrome) or [REST Easy][] (Firefox) to test requests
in your browser, or [httpie][] to test requests at the commandline.
“HTTP クライアント”とは、WP-API と関わるためにあなたが利用するツールのことを指します。
ブラウザでは [Postman][] (Chrome) や [REST Easy][] (Firefox)を、コマンドラインでは [httpie][] を使ってリクエストをテストすることができます。

WordPress itself provides a HTTP Client in the [`WP_HTTP` class][WP_HTTP] and
related functions (e.g. `wp_remote_get()`). This can be used to access one
WordPress site from another.
WordPress 自体も HTTP クライアントを提供しており、
[`WP_HTTP` class][WP_HTTP] とその関連関数群(たとえば `wp_remote_get()` )などがあり、
ある WordPress から別の WordPress にアクセスするために利用することができます。

[Postman]: https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en
[REST Easy]: https://github.com/nathan-osman/REST-Easy
[httpie]: https://github.com/jakubroztocil/httpie
[WP_HTTP]: https://codex.wordpress.org/HTTP_API

## Resource
## リソース

A "Resource" is a _discrete entity_ within WordPress. You may know these
resources already as Posts, Pages, Comments, Users, Terms, and so on. WP-API
permits HTTP clients to perform CRUD operations against resources (CRUD
stands for Create, Read, Update, and Delete).
リソースとは、WordPress 内の具体的なエンティティのことです。
Posts, Pages, Comments, Users, Terms などのことで、あなたもすでに知っているものでしょう。
WP-API は、HTTP クライアントからの、こうしたリソースに対する CRUD の実行(Create, Read, Update, Delete)を可能にします。

Pragmatically, here's how you'd typically interact with WP-API resources:
具体的にどのように WP-API リソースとインタラクトするのかを見てみましょう。

* `GET /wp-json/wp/v2/posts` to get a collection of Posts. This is roughly
equivalent to using `WP_Query`.
* `GET /wp-json/wp/v2/posts`
投稿のリストを取得。`WP_Query` に概ね対応する。

* `GET /wp-json/wp/v2/posts/123` to get a single Post with ID 123. This is
roughly equivalent to using `get_post()`.
* `GET /wp-json/wp/v2/posts/123`
ID が 123 である投稿の取得。 `get_post()` に対応。

* `POST /wp-json/wp/v2/posts` to create a new Post. This is roughly equivalent
to using `wp_insert_post()`.
* `POST /wp-json/wp/v2/posts`
新規投稿。`wp_insert_post()` に対応。

* `DELETE /wp-json/wp/v2/posts/123` to delete Post with ID 123. This is
roughly equivalent to `wp_delete_post()`.
* `DELETE /wp-json/wp/v2/posts/123`
ID が 123 の投稿を削除。`wp_delete_post()` に対応。

## Routes / Endpoints
## ルートとエンドポイント

Endpoints are functions available through the API. This can be things like
retrieving the API index, updating a post, or deleting a comment. Endpoints
perform a specific function, taking some number of parameters and return data
to the client.
エンドポイントとは、 API を通して利用可能な関数・機能のことで、
たとえば、 API のインデックスを取得したり、投稿を更新したり、
コメントを削除したりということが可能です。
エンドポイントは、いくつかのパラメータを受け付けて特定の関数を実行し、クライアントにデータを返します。

A route is the "name" you use to access endpoints, used in the URL. A route
can have multiple endpoints associated with it, and which is used depends on
the HTTP verb.
ルートとは、エンドポイントにアクセスするための”名前”のことで、URL の形で利用されます。ひとつのルートは複数のエンドポイントと関連付けられることが可能です。どのエンドポイントに関連付けられるのかは、 HTTP verbs に依って変わります。

For example, with the URL `http://example.com/wp-json/wp/v2/posts/123`:
`http://example.com/wp-json/wp/v2/posts/123` という URL を例に取ると、

* The "route" is `wp/v2/posts/123` - The route doesn't include `wp-json`
because `wp-json` is the base path for the API itself.
* ルートは `wp/v2/posts/123` となります。- ルートは `wp-json` を含みません。なぜなら、 `wp-json` は API 自身の base path であるからです。

* This route has 3 endpoints:
* このルーツには3つのエンドポイントがあります。

* `GET` triggers a `get_item` method, returning the post data to the client.
* `PUT` triggers an `update_item` method, taking the data to update, and
returning the updated post data.
* `DELETE` triggers a `delete_item` method, returning the now-deleted post
data to the client.
* `GET` は `get_item` メソッドのトリガーとなり、投稿データをクライアントに返します。
* `PUT` は `update_item` メソッドのトリガーとなり、更新のためのデータを受け取って更新後の投稿データを返します。
* `DELETE` は `delete_item` メソッドのトリガーとなり、消したばかりの投稿データをクライアントに返します。

**Note:** On sites without pretty permalinks, the route is instead added to
the URL as the `rest_route` parameter. For the above example, the full URL
would then be `http://example.com/?rest_route=wp/v2/posts/123`
**注意:** pretty permalink を有効にしていないサイトでは、
ルートは `rest_route` パラメータとして URL に追加されます。
上記の例で言えば、 `http://example.com/?rest_route=wp/v2/posts/123` がその場合の完全な URL となります。

## Schema
## スキーマ

A "schema" is a representation of the format for WP-API's response data. For
instance, the Post schema communicates that a request to get a Post will
return `id`, `title`, `content`, `author`, and other fields. Our schemas also
indicate the type each field is, provide a human-readable description, and
show which contexts the field will be returned in.
スキーマとは、 WP-API のレスポンスデータの形式(フォーマット)を表す言葉です。
たとえば、Post スキーマは、Post が `id`、 `title`、 `content`、 `author`、その他のフィールドを返すようにリクエストを伝達します。
WP-API のスキーマは、各フィールドのタイプを示したり、人間に理解可能なディスクリプションを提供したり、
フィールドが返されるコンテクストを表示したりもします。