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 controller.md (v5.5) #362

Merged
merged 2 commits into from
Nov 14, 2017

Conversation

Nationalcat
Copy link
Collaborator

Translate controller.md (v5.5)

  1. 已同步原始文件最近的更新

@Nationalcat Nationalcat mentioned this pull request Oct 31, 2017
73 tasks
Copy link
Member

@neighborhood999 neighborhood999 left a comment

Choose a reason for hiding this comment

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

再麻煩檢查一下程式碼註解部分有沒有缺漏翻譯的,謝謝!

controllers.md Outdated
- [部分資源路由](#restful-partial-resource-routes)
- [為資源路由命名](#restful-naming-resource-routes)
- [為資源路由命名的參數](#restful-naming-resource-route-parameters)
- [在地化資源的 URI](#restful-localizing-resource-uris)
Copy link
Member

Choose a reason for hiding this comment

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

「本地化」感覺比較好一些

controllers.md Outdated

Below is an example of a basic controller class. Note that the controller extends the base controller class included with Laravel. The base class provides a few convenience methods such as the `middleware` method, which may be used to attach middleware to controller actions:
這是一個基礎控制器類別的範例。所有 Laravel 控制器都應繼承基礎控制器類別,它包含在 Laravel 的預設安裝中:
Copy link
Member

Choose a reason for hiding this comment

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

以下是一個基礎控制器類別的範例。注意 Laravel 控制器都應繼承基礎控制器類別。基礎類別提供了一些方便的方法,像是 middleware 方法,可以把中介層附加到控制器的行為:

controllers.md Outdated

Route::get('user/{id}', 'UserController@show');

Now, when a request matches the specified route URI, the `show` method on the `UserController` class will be executed. Of course, the route parameters will also be passed to the method.
現在,當請求和此特定的路由 URI 相匹配時,`UserController` 類別的 `showProfile` 方法就會被執行。當然,路由的參數也會被傳遞至該方法。
Copy link
Member

Choose a reason for hiding this comment

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

現在,當一個請求匹配指定的路由 URI 時,在 UserController 類別的 show 方法將會被執行。當然,路由參數也可以被傳送到方法。

controllers.md Outdated

> {tip} Controllers are not **required** to extend a base class. However, you will not have access to convenience features such as the `middleware`, `validate`, and `dispatch` methods.
> {tip} 控制器不**需要**再繼承基礎類別。然而,你將無法存取一些方便的功能,比如 `middleware``validate` `dispatch` 這些方法。
Copy link
Member

Choose a reason for hiding this comment

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

控制器不需要強制去繼承基礎類別。然而,你將無法存取一些方便的功能,像是 middlewarevalidatedispatch 這些方法。

controllers.md Outdated

It is very important to note that we did not need to specify the full controller namespace when defining the controller route. Since the `RouteServiceProvider` loads your route files within a route group that contains the namespace, we only specified the portion of the class name that comes after the `App\Http\Controllers` portion of the namespace.
有一點非常重要,那就是我們在定義控制器路由時,不需要指定完整的控制器命名空間。因為 `RouteServiceProvider` 已經把命名空間寫入路由群組中,並且會載到你的路由檔案,我們只需要指定 `App\Http\Controllers` 命名空間之後的類別名稱部分。
Copy link
Member

Choose a reason for hiding this comment

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

有一點非常重要,當我們在定義控制器路由時,我們不需要指定完整的控制器命名空間。由於 RouteServiceProvider 載入你的路由檔案內的路由群組包含了命名空間,我們只需要指定命名空間 App\Http\Controllers 部分之後的類別名稱部分。

controllers.md Outdated

/user/{admin_user}

<a name="restful-localizing-resource-uris"></a>
### Localizing Resource URIs
### 在地化資源的 URI
Copy link
Member

Choose a reason for hiding this comment

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

本地化

controllers.md Outdated

By default, `Route::resource` will create the route parameters for your resource routes based on the "singularized" version of the resource name. You can easily override this on a per resource basis by passing `parameters` in the options array. The `parameters` array should be an associative array of resource names and parameter names:
預設的 `Route::resource` 會根據「奇數」版本的資源名稱建立資源路由的路由參數。你能透過在選項陣列中傳遞 `parameters` 來輕鬆的覆蓋每個資源。`parameters` 陣列應該是與資源名稱或參數名稱有關的陣列:
Copy link
Member

Choose a reason for hiding this comment

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

預設上,Route::resource 會根據「單一化」版本的資源名稱建立資源路由的路由參數。你能透過在選項陣列中傳遞 parameters 來輕鬆的覆蓋每個資源。parameters 陣列應該是與資源名稱或參數名稱有關的陣列:

controllers.md Outdated

By default, `Route::resource` will create resource URIs using English verbs. If you need to localize the `create` and `edit` action verbs, you may use the `Route::resourceVerbs` method. This may be done in the `boot` method of your `AppServiceProvider`:
預設 `Route::resource` 會使用英文動詞來建立資源的 URI。如果你需要將 `create` `edit` 行為動詞給在地化翻譯,你可以使用 `Route::resourceVerbs` 方法。這可以在你的 `AppServiceProvider` 的 `boot` 方法中完成這件事:
Copy link
Member

Choose a reason for hiding this comment

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

本地化翻譯

controllers.md Outdated

Route::get('photos/popular', 'PhotoController@method');

Route::resource('photos', 'PhotoController');

> {tip} Remember to keep your controllers focused. If you find yourself routinely needing methods outside of the typical set of resource actions, consider splitting your controller into two, smaller controllers.
> {tip} 請記得維持控制器的重點。如果你發現自己經常需要用到典型資源以外的方法,建議將控制器拆分為兩個較小的控制器。
Copy link
Member

Choose a reason for hiding this comment

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

記住要保持你的控制器的重點。

controllers.md Outdated

In addition to constructor injection, you may also type-hint dependencies on your controller's methods. A common use-case for method injection is injecting the `Illuminate\Http\Request` instance into your controller methods:
除了建構子注入外,你也可以在你的控制器方法上注入依賴。方法注入的常用案例是注入 `Illuminate\Http\Request` 實例到你的控制器方法:
Copy link
Member

Choose a reason for hiding this comment

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

除了建構子注入外,你也可以在你的控制器的方法上類型提示依賴。

@neighborhood999 neighborhood999 merged commit 9a673c1 into laravel-taiwan:5.5 Nov 14, 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