Browse Source

update block name

tags/2.0.16
cuileon 7 years ago
parent
commit
ebc1f0ceaf
  1. 4
      docs/guide-zh-CN/caching-data.md
  2. 2
      docs/guide-zh-CN/caching-http.md
  3. 4
      docs/guide-zh-CN/concept-autoloading.md
  4. 4
      docs/guide-zh-CN/concept-behaviors.md
  5. 10
      docs/guide-zh-CN/concept-di-container.md
  6. 4
      docs/guide-zh-CN/concept-events.md
  7. 2
      docs/guide-zh-CN/concept-properties.md
  8. 8
      docs/guide-zh-CN/db-active-record.md
  9. 10
      docs/guide-zh-CN/db-dao.md
  10. 6
      docs/guide-zh-CN/db-migrations.md
  11. 2
      docs/guide-zh-CN/db-query-builder.md
  12. 2
      docs/guide-zh-CN/input-file-upload.md
  13. 4
      docs/guide-zh-CN/input-forms.md
  14. 20
      docs/guide-zh-CN/input-validation.md
  15. 4
      docs/guide-zh-CN/output-data-widgets.md
  16. 4
      docs/guide-zh-CN/output-formatting.md
  17. 2
      docs/guide-zh-CN/output-pagination.md
  18. 2
      docs/guide-zh-CN/rest-authentication.md
  19. 8
      docs/guide-zh-CN/rest-quick-start.md
  20. 2
      docs/guide-zh-CN/rest-resources.md
  21. 2
      docs/guide-zh-CN/rest-routing.md
  22. 8
      docs/guide-zh-CN/runtime-handling-errors.md
  23. 8
      docs/guide-zh-CN/runtime-responses.md
  24. 20
      docs/guide-zh-CN/runtime-routing.md
  25. 12
      docs/guide-zh-CN/runtime-sessions-cookies.md
  26. 4
      docs/guide-zh-CN/security-authorization.md
  27. 6
      docs/guide-zh-CN/start-databases.md
  28. 10
      docs/guide-zh-CN/start-forms.md
  29. 4
      docs/guide-zh-CN/start-gii.md
  30. 4
      docs/guide-zh-CN/start-hello.md
  31. 2
      docs/guide-zh-CN/structure-application-components.md
  32. 6
      docs/guide-zh-CN/structure-applications.md
  33. 24
      docs/guide-zh-CN/structure-assets.md
  34. 4
      docs/guide-zh-CN/structure-controllers.md
  35. 2
      docs/guide-zh-CN/structure-filters.md
  36. 10
      docs/guide-zh-CN/structure-models.md
  37. 4
      docs/guide-zh-CN/structure-modules.md
  38. 2
      docs/guide-zh-CN/structure-views.md
  39. 4
      docs/guide-zh-CN/structure-widgets.md
  40. 2
      docs/guide-zh-CN/test-environment-setup.md
  41. 4
      docs/guide-zh-CN/tutorial-i18n.md
  42. 2
      docs/guide-zh-CN/tutorial-yii-integration.md

4
docs/guide-zh-CN/caching-data.md

@ -294,7 +294,7 @@ $result = Customer::getDb()->cache(function ($db) {
});
```
> Info: 有些 DBMS (例如:[MySQL](http://dev.mysql.com/doc/refman/5.1/en/query-cache.html))
> 信息:有些 DBMS (例如:[MySQL](http://dev.mysql.com/doc/refman/5.1/en/query-cache.html))
也支持数据库服务器端的查询缓存。
你可以选择使用任一查询缓存机制。
上文所述的查询缓存的好处在于你可以指定更灵活的缓存依赖因此可能更加高效。
@ -309,7 +309,7 @@ $result = Customer::getDb()->cache(function ($db) {
- `yii cache/flush cache1 cache2`: 冲刷缓存组件`cache1`, `cache2` (可以传递多个用空格分开的缓存组件)
- `yii cache/flush-all`: 冲刷应用中所有的缓存组件
> Info: 默认情况下,控制台应用使用独立的配置文件。所以,为了上述命令发挥作用,请确保Web应用和控制台应用配置相同的缓存组件。
> 信息:默认情况下,控制台应用使用独立的配置文件。所以,为了上述命令发挥作用,请确保Web应用和控制台应用配置相同的缓存组件。
### 配置 <span id="query-caching-configs"></span>

2
docs/guide-zh-CN/caching-http.md

@ -107,7 +107,7 @@ ETag 相比 `Last-Modified` 能实现更复杂和更精确的缓存策略。
因为响应每一次请求都需要重新计算 Etag。
请试着找出一个最简单的表达式去触发 Etag 失效。
> Note: 为了遵循 [RFC 7232(HTTP 1.1 协议)](http://tools.ietf.org/html/rfc7232#section-2.4),
> 注意:为了遵循 [RFC 7232(HTTP 1.1 协议)](http://tools.ietf.org/html/rfc7232#section-2.4),
如果同时配置了 `ETag``Last-Modified` 头,`HttpCache` 将会同时发送它们。
并且如果客户端同时发送 `If-None-Match` 头和 `If-Modified-Since` 头,
则只有前者会被接受。

4
docs/guide-zh-CN/concept-autoloading.md

@ -6,7 +6,7 @@ Yii 依靠[类自动加载机制](http://www.php.net/manual/en/language.oop5.aut
([中文汉化](https://github.com/hfcorriez/fig-standards/blob/zh_CN/%E6%8E%A5%E5%8F%97/PSR-4-autoloader.md))的自动加载器。
该自动加载器会在引入框架文件 `Yii.php` 时安装好。
> Note: 为了简化叙述,本篇文档中我们只会提及类的自动加载。
> 注意:为了简化叙述,本篇文档中我们只会提及类的自动加载。
不过,要记得文中的描述同样也适用于接口和Trait(特质)的自动加载哦。
@ -80,7 +80,7 @@ require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
不过这样做的话,类的加载效率会下降,
且你必须遵循 Composer 所设定的规则,从而让你的类满足可以被自动加载的要求。
> Info: 若你不想要使用 Yii 的自动加载器,你必须创建一个你自己版本的 `Yii.php` 文件,
> 信息:若你不想要使用 Yii 的自动加载器,你必须创建一个你自己版本的 `Yii.php` 文件,
并把它包含进你的[入口脚本](structure-entry-scripts.md)里。

4
docs/guide-zh-CN/concept-behaviors.md

@ -50,7 +50,7 @@ class MyBehavior extends Behavior
> 提示:在行为内部可以通过 [[yii\base\Behavior::owner]] 属性访问行为已附加的组件。
> Note: In case [[yii\base\Behavior::__get()]] and/or [[yii\base\Behavior::__set()]] method of behavior is overridden you
> 注意:In case [[yii\base\Behavior::__get()]] and/or [[yii\base\Behavior::__set()]] method of behavior is overridden you
need to override [[yii\base\Behavior::canGetProperty()]] and/or [[yii\base\Behavior::canSetProperty()]] as well.
处理事件
@ -291,7 +291,7 @@ class User extends ActiveRecord
`created_at``updated_at` 属性;
* 当记录更新时,行为将当前时间戳赋值给 `updated_at` 属性。
> Note: For the above implementation to work with MySQL database, please declare the columns(`created_at`, `updated_at`) as int(11) for being UNIX timestamp.
> 注意:For the above implementation to work with MySQL database, please declare the columns(`created_at`, `updated_at`) as int(11) for being UNIX timestamp.
With that code in place, if you have a `User` object and try to save it, you will find its `created_at` and `updated_at` are automatically
filled with the current UNIX timestamp:

10
docs/guide-zh-CN/concept-di-container.md

@ -103,7 +103,7 @@ $container->get('Foo', [], [
]);
```
> Info: The [[yii\di\Container::get()]] method takes its third parameter as a configuration array that should
> 信息:The [[yii\di\Container::get()]] method takes its third parameter as a configuration array that should
be applied to the object being created. If the class implements the [[yii\base\Configurable]] interface (e.g.
[[yii\base\BaseObject]]), the configuration array will be passed as the last parameter to the class constructor;
otherwise, the configuration will be applied *after* the object is created.
@ -199,7 +199,7 @@ $container->set('db', function ($container, $params, $config) {
$container->set('pageCache', new FileCache);
```
> Tip: 如果依赖关系名称和依赖关系的定义相同,
> 提示:如果依赖关系名称和依赖关系的定义相同,
则不需要通过 DI 容器注册该依赖关系。
通过 `set()` 注册的依赖关系,在每次使用时都会产生一个新实例。
@ -336,7 +336,7 @@ echo \yii\widgets\LinkPager::widget();
echo \yii\widgets\LinkPager::widget(['maxButtonCount' => 20]);
```
> Note: Properties given in the widget call will always override the definition in the DI container.
> 注意:Properties given in the widget call will always override the definition in the DI container.
> Even if you specify an array, e.g. `'options' => ['id' => 'mypager']` these will not be merged
> with other options but replace them.
@ -431,7 +431,7 @@ $reader = $container->get('app\storage\DocumentsReader);
// Will create DocumentReader object with its dependencies as described in the config
```
> Tip: Container may be configured in declarative style using application configuration since version 2.0.11.
> 提示:Container may be configured in declarative style using application configuration since version 2.0.11.
Check out the [Application Configurations](concept-configurations.md#application-configurations) subsection of
the [Configurations](concept-configurations.md) guide article.
@ -473,7 +473,7 @@ You might notice `Instance::of('tempFileStorage')` notation. It means, that the
will implicitly provide a dependency registered with the name of `tempFileStorage` and pass it as the first argument
of `app\storage\DocumentsWriter` constructor.
> Note: [[yii\di\Container::setDefinitions()|setDefinitions()]] and [[yii\di\Container::setSingletons()|setSingletons()]]
> 注意:[[yii\di\Container::setDefinitions()|setDefinitions()]] and [[yii\di\Container::setSingletons()|setSingletons()]]
methods are available since version 2.0.11.
Another step on configuration optimization is to register some dependencies as singletons.

4
docs/guide-zh-CN/concept-events.md

@ -124,7 +124,7 @@ class Foo extends Component
以上代码当调用 `bar()` ,它将触发名为 `hello` 的事件。
> Tip: 推荐使用类常量来表示事件名。上例中,常量 `EVENT_HELLO` 用来表示 `hello`
> 提示:推荐使用类常量来表示事件名。上例中,常量 `EVENT_HELLO` 用来表示 `hello`
这有两个好处。第一,它可以防止拼写错误并支持 IDE 的自动完成。
第二,只要简单检查常量声明就能了解一个类支持哪些事件。
@ -238,7 +238,7 @@ Event::trigger(Foo::className(), Foo::EVENT_HELLO);
注意这种情况下 `$event->sender` 指向触发事件的类名而不是对象实例。
> Note: 因为类级别的处理器响应类和其子类的所有实例触发的事件,
> 注意:因为类级别的处理器响应类和其子类的所有实例触发的事件,
必须谨慎使用,尤其是底层的基类,如 [[yii\base\Object]]。
移除类级别的事件处理器只需调用[[yii\base\Event::off()]],如:

2
docs/guide-zh-CN/concept-properties.md

@ -20,7 +20,7 @@ $object->label = trim($label);
它支持基于类内的 **getter****setter**(读取器和设定器)方法来定义属性。
如果某类需要支持这个特性,只需要继承 [[yii\base\Object]] 或其子类即可。
> Info: 几乎每个 Yii 框架的核心类都继承自 [[yii\base\Object]] 或其子类。
> 信息:几乎每个 Yii 框架的核心类都继承自 [[yii\base\Object]] 或其子类。
这意味着只要在核心类中见到 getter 或 setter 方法,就可以像调用属性一样调用它。
getter 方法是名称以 `get` 开头的方法,而 setter 方法名以 `set` 开头。

8
docs/guide-zh-CN/db-active-record.md

@ -168,7 +168,7 @@ $sql = 'SELECT * FROM customer';
$customers = Customer::findBySql($sql)->all();
```
> Tip: 在上面的代码中,`Customer::STATUS_ACTIVE` 是一个在 `Customer` 类里定义的常量。(译注:这种常量的值一般都是tinyint)相较于直接在代码中写死字符串或数字,使用一个更有意义的常量名称是一种更好的编程习惯。
> 提示:在上面的代码中,`Customer::STATUS_ACTIVE` 是一个在 `Customer` 类里定义的常量。(译注:这种常量的值一般都是tinyint)相较于直接在代码中写死字符串或数字,使用一个更有意义的常量名称是一种更好的编程习惯。
有两个快捷方法:`findOne` 和 `findAll()` 用来返回一个或者一组`ActiveRecord`实例。前者返回第一个匹配到的实例,后者返回所有。
例如:
@ -407,7 +407,7 @@ SELECT * FROM customer WHERE id=1;
SELECT * FROM order WHERE customer_id=1;
```
> Tip: 再次用表达式 `$customer->orders`将不会执行第二次 SQL 查询,
> 提示:再次用表达式 `$customer->orders`将不会执行第二次 SQL 查询,
SQL 查询只在该表达式第一次使用时执行。
数据库访问只返回缓存在内部前一次取回的结果集,如果你想查询新的
关联数据,先要注销现有结果集:`unset($customer->orders);`。
@ -438,7 +438,7 @@ class Customer extends \yii\db\ActiveRecord
$orders = $customer->getBigOrders(200)->all();
```
> Note: 关联查询返回的是 [[yii\db\ActiveQuery]] 的实例,如果像特性(如类属性)那样连接关联数据,
> 注意:关联查询返回的是 [[yii\db\ActiveQuery]] 的实例,如果像特性(如类属性)那样连接关联数据,
返回的结果是关联查询的结果,即 [[yii\db\ActiveRecord]] 的实例,
或者是数组,或者是 null ,取决于关联关系的多样性。如,`$customer->getOrders()` 返回
`ActiveQuery` 实例,而 `$customer->orders` 返回`Order` 对象数组
@ -632,7 +632,7 @@ if ($customers[0]->orders[0]->customer === $customers[0]) {
}
```
> Note: 相对关系不能在包含中间表的关联关系中定义。 即是,如果你的关系是通过[[yii\db\ActiveQuery::via()|via()]] 或 [[yii\db\ActiveQuery::viaTable()|viaTable()]]方法定义的, 就不能调用[[yii\db\ActiveQuery::inverseOf()]]方法了。
> 注意:相对关系不能在包含中间表的关联关系中定义。 即是,如果你的关系是通过[[yii\db\ActiveQuery::via()|via()]] 或 [[yii\db\ActiveQuery::viaTable()|viaTable()]]方法定义的, 就不能调用[[yii\db\ActiveQuery::inverseOf()]]方法了。
JOIN 类型关联查询

10
docs/guide-zh-CN/db-dao.md

@ -57,7 +57,7 @@ return [
之后你就可以通过语句 `Yii::$app->db` 来使用数据库连接了。
> Tip: 如果你的应用需要访问多个数据库,你可以配置多个 DB 应用组件。
> 提示:如果你的应用需要访问多个数据库,你可以配置多个 DB 应用组件。
配置数据库连接时, 你应该总是通过 [[yii\db\Connection::dsn|dsn]] 属性来指明它的数据源名称 (DSN) 。
不同的数据库有着不同的 DSN 格式。
@ -92,11 +92,11 @@ return [
你常常需要配置 [[yii\db\Connection::username|username]] 和 [[yii\db\Connection::password|password]]。
请参考 [[yii\db\Connection]] 来获取完整的可配置属性列表。
> Info: 当你实例化一个 DB Connection 时,
> 信息:当你实例化一个 DB Connection 时,
直到你第一次执行 SQL 或者你明确地调用 [[yii\db\Connection::open()|open()]] 方法时,
才建立起实际的数据库连接。
> Tip: 有时你可能想要在建立起数据库连接时立即执行一些语句来初始化一些环境变量 (比如设置时区或者字符集),
> 提示:有时你可能想要在建立起数据库连接时立即执行一些语句来初始化一些环境变量 (比如设置时区或者字符集),
> 你可以通过为数据库连接的 [[yii\db\Connection::EVENT_AFTER_OPEN|afterOpen]] 事件注册一个事件处理器来达到目的。
> 你可以像这样直接在应用配置中注册处理器:
>
@ -525,7 +525,7 @@ $rows = Yii::$app->db->createCommand('SELECT * FROM user LIMIT 10')->queryAll();
Yii::$app->db->createCommand("UPDATE user SET username='demo' WHERE id=1")->execute();
```
> Info: 通过调用 [[yii\db\Command::execute()]] 来执行的语句都被视为写操作,
> 信息:通过调用 [[yii\db\Command::execute()]] 来执行的语句都被视为写操作,
而其他所有通过调用 [[yii\db\Command]] 中任一 "query" 方法来执行的语句都被视为读操作。
你可以通过 `Yii::$app->db->slave` 来获取当前有效的从库连接。
@ -540,7 +540,7 @@ Yii::$app->db->createCommand("UPDATE user SET username='demo' WHERE id=1")->exec
一个“挂掉的”服务器将会被记住,
因此,在一个 yii\db\Connection::serverRetryInterval 内将不再试着连接该服务器。
> Info: 在上面的配置中,
> 信息:在上面的配置中,
每个从库都共同地指定了 10 秒的连接超时时间,
这意味着,如果一个从库在 10 秒内不能被连接上,
它将被视为“挂掉的”。

6
docs/guide-zh-CN/db-migrations.md

@ -296,7 +296,7 @@ class m150811_220037_create_post extends Migration
}
```
> Note: primary key is added automatically and is named `id` by default. If you want to use another name you may
> 注意:primary key is added automatically and is named `id` by default. If you want to use another name you may
> specify it explicitly like `--fields="name:primaryKey"`.
#### Foreign keys
@ -693,7 +693,7 @@ class m150101_185401_create_news_table extends Migration
这是因为通常你是不需要去数据库把数据一行一行查出来再显示出来的。
另外一个原因是你完全可以使用强大的 [Query Builder 查询构建器](db-query-builder.md) 来构建和查询。
> Note: When manipulating data using a migration you may find that using your [Active Record](db-active-record.md) classes
> 注意:When manipulating data using a migration you may find that using your [Active Record](db-active-record.md) classes
> for this might be useful because some of the logic is already implemented there. Keep in mind however, that in contrast
> to code written in the migrations, who's nature is to stay constant forever, application logic is subject to change.
> So when using Active Record in migration code, changes to the logic in the Active Record layer may accidentally break
@ -714,7 +714,7 @@ yii migrate
如果其中任意一个迁移提交失败了,
那么这条命令将会退出并停止剩下的那些还未执行的迁移。
> Tip: In case you don't have command line at your server you may try [web shell](https://github.com/samdark/yii2-webshell)
> 提示:In case you don't have command line at your server you may try [web shell](https://github.com/samdark/yii2-webshell)
> extension.
对于每一个成功提交的迁移,这条命令都会在一个叫做 `migration`

2
docs/guide-zh-CN/db-query-builder.md

@ -634,7 +634,7 @@ $query = (new \yii\db\Query())
该匿名函数将带有一个包含了当前行的数据的 `$row` 参数,并且返回用作当前行索引的
标量值(译者注:就是简单的数值或者字符串,而不是其他复杂结构,例如数组)。
> Note: In contrast to query methods like [[yii\db\Query::groupBy()|groupBy()]] or [[yii\db\Query::orderBy()|orderBy()]]
> 注意:In contrast to query methods like [[yii\db\Query::groupBy()|groupBy()]] or [[yii\db\Query::orderBy()|orderBy()]]
> which are converted to SQL and are part of the query, this method works after the data has been fetched from the database.
> That means that only those column names can be used that have been part of SELECT in your query.
> Also if you selected a column with table prefix, e.g. `customer.id`, the result set will only contain `id` so you have to call

2
docs/guide-zh-CN/input-file-upload.md

@ -77,7 +77,7 @@ use yii\widgets\ActiveForm;
需要注意的是要记得在表单选项里加入 `enctype` 属性以确保文件能被正常上传。
`fileInput()` 方法会渲染一个 `<input type="file">` 标签,让用户可以选择一个文件上传。
> Tip: since version 2.0.8, [[yii\web\widgets\ActiveField::fileInput|fileInput]] adds `enctype` option to the form
> 提示:since version 2.0.8, [[yii\web\widgets\ActiveField::fileInput|fileInput]] adds `enctype` option to the form
automatically when file input field is used.
## 视图和模型的连接 <span id="wiring-up"></span>

4
docs/guide-zh-CN/input-forms.md

@ -78,7 +78,7 @@ input 输入框的 name 属性会自动地根据 [[yii\base\Model::formName()|fo
例如,对于在上面的例子中 `username` 输入字段的 name 属性将是 `LoginForm[username]`
这种命名规则使所有属性的数组的登录表单在服务器端的 `$_POST['LoginForm']` 数组中是可用的。
> Tip: If you have only one model in a form and want to simplify the input names you may skip the array part by
> 提示:If you have only one model in a form and want to simplify the input names you may skip the array part by
> overriding the [[yii\base\Model::formName()|formName()]] method of the model to return an empty string.
> This can be useful for filter models used in the [GridView](output-data-widgets.md#grid-view) to create nicer URLs.
@ -168,7 +168,7 @@ Pjax::begin([
ActiveForm::end();
Pjax::end();
```
> Tip: Be careful with the links inside the [[yii\widgets\Pjax|Pjax]] widget since
> 提示:Be careful with the links inside the [[yii\widgets\Pjax|Pjax]] widget since
> the response will also be rendered inside the widget. To prevent this, use the
> `data-pjax="0"` HTML attribute.

20
docs/guide-zh-CN/input-validation.md

@ -96,7 +96,7 @@ public function rules()
方法里的激活特性,且它还必须与一或多个声明自
`rules()` 里的激活规则相关联才会被验证。
> Note: It is handy to give names to rules i.e.
> 注意:It is handy to give names to rules i.e.
> ```php
> public function rules()
> {
@ -252,7 +252,7 @@ return [
}]
```
> Note: 对于绝大多数验证器而言,若其 [[yii\base\Validator::skipOnEmpty]] 属性为默认值
> 注意:对于绝大多数验证器而言,若其 [[yii\base\Validator::skipOnEmpty]] 属性为默认值
true,则它们不会对空值进行任何处理。也就是当他们的关联特性接收到空值时,相关验证会被直接略过。在
[核心验证器](tutorial-core-validators.md) 之中,只有 `captcha`(验证码),`default`(默认值),
`filter`(滤镜),`required`(必填),以及 `trim`(去首尾空格),这几个验证器会处理空输入。
@ -276,7 +276,7 @@ if ($validator->validate($email, $error)) {
}
```
> Note: 不是所有的验证器都支持这种形式的验证。比如 [unique(唯一性)](tutorial-core-validators.md#unique)核心验证器就就是一个例子,
> 注意:不是所有的验证器都支持这种形式的验证。比如 [unique(唯一性)](tutorial-core-validators.md#unique)核心验证器就就是一个例子,
它的设计初衷就是只作用于模型类内部的。
若你需要针对一系列值执行多项验证,你可以使用 [[yii\base\DynamicModel]]
@ -383,7 +383,7 @@ class MyForm extends Model
}
```
> Note: 缺省状态下,行内验证器不会在关联特性的输入值为空或该特性已经在其他验证中失败的情况下起效。
> 注意:缺省状态下,行内验证器不会在关联特性的输入值为空或该特性已经在其他验证中失败的情况下起效。
若你想要确保该验证器始终启用的话,你可以在定义规则时,酌情将
[[yii\validators\Validator::skipOnEmpty|skipOnEmpty]] 以及
[[yii\validators\Validator::skipOnError|skipOnError]]属性设为 false,比如,
@ -459,7 +459,7 @@ class EntryForm extends Model
因为,它可以让用户更快速的得到错误信息,也因此可以提供更好的用户体验。
你可以使用或自己实现除服务器端验证之外,**还能额外**客户端验证功能的验证器。
> Info: 尽管客户端验证为加分项,但它不是必须项。它存在的主要意义在于给用户提供更好的客户体验。
> 信息:尽管客户端验证为加分项,但它不是必须项。它存在的主要意义在于给用户提供更好的客户体验。
正如“永远不要相信来自终端用户的输入信息”,也同样永远不要相信客户端验证。基于这个理由,
你应该始终如前文所描述的那样,通过调用 [[yii\base\Model::validate()]]
方法执行服务器端验证。
@ -579,7 +579,7 @@ JS;
}
```
> Tip: 上述代码主要是演示了如何支持客户端验证。在具体实践中,
> 提示:上述代码主要是演示了如何支持客户端验证。在具体实践中,
> 你可以使用 [in](tutorial-core-validators.md#in) 核心验证器来达到同样的目的。
> 比如这样的验证规则:
>
@ -589,7 +589,7 @@ JS;
> ]
> ```
> Tip: If you need to work with client validation manually i.e. dynamically add fields or do some custom UI logic, refer
> 提示:If you need to work with client validation manually i.e. dynamically add fields or do some custom UI logic, refer
> to [Working with ActiveForm via JavaScript](https://github.com/samdark/yii2-cookbook/blob/master/book/forms-activeform-js.md)
> in Yii 2.0 Cookbook.
@ -640,7 +640,7 @@ JS;
}
```
> Note: The `resolve()` method must be called after the attribute has been validated. Otherwise the main form
> 注意:The `resolve()` method must be called after the attribute has been validated. Otherwise the main form
validation will not complete.
For simplicity, the `deferred` array is equipped with a shortcut method `add()` which automatically creates a Deferred
@ -703,7 +703,7 @@ $form = ActiveForm::begin([
]);
```
> Note: When the `enableAjaxValidation` property is configured at both the input field level and the form level,
> 注意:When the `enableAjaxValidation` property is configured at both the input field level and the form level,
the former will take precedence.
You also need to prepare the server so that it can handle the AJAX validation requests.
@ -719,7 +719,7 @@ if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
The above code will check whether the current request is an AJAX. If yes, it will respond to
this request by running the validation and returning the errors in JSON format.
> Info: You can also use [Deferred Validation](#deferred-validation) to perform AJAX validation.
> 信息:You can also use [Deferred Validation](#deferred-validation) to perform AJAX validation.
However, the AJAX validation feature described here is more systematic and requires less coding effort.
When both `enableClientValidation` and `enableAjaxValidation` are set to true, AJAX validation request will be triggered

4
docs/guide-zh-CN/output-data-widgets.md

@ -397,7 +397,7 @@ class PostSearch extends Post
}
```
> Tip: See [Query Builder](db-query-builder.md) and especially [Filter Conditions](db-query-builder.md#filter-conditions)
> 提示:See [Query Builder](db-query-builder.md) and especially [Filter Conditions](db-query-builder.md#filter-conditions)
> to learn how to build filtering query.
你可以在控制器中使用如下方法为网格视图获取数据提供者:
@ -465,7 +465,7 @@ and include it in `index.php` view like so:
<?= $this->render('_search', ['model' => $searchModel]) ?>
```
> Note: if you use Gii to generate CRUD code, the separate filter form (`_search.php`) is generated by default,
> 注意:if you use Gii to generate CRUD code, the separate filter form (`_search.php`) is generated by default,
but is commented in `index.php` view. Uncomment it and it's ready to use!
Separate filter form is useful when you need to filter by fields, that are not displayed in GridView

4
docs/guide-zh-CN/output-formatting.md

@ -40,7 +40,7 @@ echo Yii::$app->formatter->format('2014-01-01', 'date');
echo Yii::$app->formatter->format(0.125, ['percent', 2]);
```
> Note: `formatter` 组件用来格式化最终展示给用户的数据.
> 注意:`formatter` 组件用来格式化最终展示给用户的数据.
> 如果你想要将用户的输入进行格式化或者只是将一些别的日期数据进行格式化(这里的格式化说的是机器可读的格式化),不要使用这个组件,
> 而应该使用 [[yii\validators\DateValidator]] 和 [[yii\validators\NumberValidator]] 进行用户输入格式化
> 关于日期格式化,戳这里 [date()](http://php.net/manual/en/function.date.php)
@ -193,7 +193,7 @@ echo Yii::$app->formatter->asDate('2014-01-01'); // output: 1 января 2014
默认配置下,当前 [[yii\i18n\Formatter::locale|locale]] 决定于 [[yii\base\Application::language]].
你可以覆盖 [[yii\i18n\Formatter::locale]] 属性来满足不同的需要。
> Note: Yii formatter 依赖 [PHP intl extension](http://php.net/manual/en/book.intl.php) 来进行本地数据格式化
> 注意:Yii formatter 依赖 [PHP intl extension](http://php.net/manual/en/book.intl.php) 来进行本地数据格式化
> 因为不同的 ICU 库可能会导致不同的输出,所以请在你的所有机器上保持 ICU 库的一致性.
> 请戳 [Setting up your PHP environment for internationalization](tutorial-i18n.md#setup-environment).
>

2
docs/guide-zh-CN/output-pagination.md

@ -72,4 +72,4 @@ echo $pagination->createUrl(100);
echo $pagination->createUrl(101);
```
> Tip: 创建分页对象时,你可以通过配置 [[yii\data\Pagination::pageParam|pageParam]] 属性来自定义查询参数 `page` 的名字。
> 提示:创建分页对象时,你可以通过配置 [[yii\data\Pagination::pageParam|pageParam]] 属性来自定义查询参数 `page` 的名字。

2
docs/guide-zh-CN/rest-authentication.md

@ -36,7 +36,7 @@ Yii 支持上述的认证方式,你也可很方便的创建新的认证方式
当[[yii\web\User::enableSession|enableSession]]为false,
请求中的用户认证状态就不能通过session来保持,每个请求的认证通过步骤2和3来实现。
> Tip: 如果你将RESTful APIs作为应用开发,可以设置应用配置中 `user` 组件的
> 提示:如果你将RESTful APIs作为应用开发,可以设置应用配置中 `user` 组件的
> [[yii\web\User::enableSession|enableSession]],
> 如果将RESTful APIs作为模块开发,可以在模块的 `init()` 方法中增加如下代码,如下所示:

8
docs/guide-zh-CN/rest-quick-start.md

@ -60,7 +60,7 @@ class UserController extends ActiveController
上面的配置主要是为`user`控制器增加一个 URL 规则。这样,
用户的数据就能通过美化的 URL 和有意义的 http 动词进行访问和操作。
> Note: Yii will automatically pluralize controller names for use in endpoints (see [Trying it Out](#trying-it-out) section below).
> 注意:Yii will automatically pluralize controller names for use in endpoints (see [Trying it Out](#trying-it-out) section below).
> You can configure this using the [[yii\rest\UrlRule::$pluralize]] property.
@ -77,7 +77,7 @@ class UserController extends ActiveController
]
```
> Info: 上述配置是可选的。若未按上述配置,API 将仅可以分辨
> 信息:上述配置是可选的。若未按上述配置,API 将仅可以分辨
`application/x-www-form-urlencoded``multipart/form-data` 输入格式。
@ -172,7 +172,7 @@ Content-Type: application/json; charset=UTF-8
{"id":1,"username":"example","email":"user@example.com","created_at":1414674789,"updated_at":1414674789}
```
> Tip: 你还可以通过 Web 浏览器中输入 URL `http://localhost/users` 来访问你的 API。
> 提示:你还可以通过 Web 浏览器中输入 URL `http://localhost/users` 来访问你的 API。
尽管如此,你可能需要一些浏览器插件来发送特定的 headers 请求。
如你所见,在 headers 响应,有关于总数,页数的信息,等等。
@ -183,7 +183,7 @@ Content-Type: application/json; charset=UTF-8
例如:URL `http://localhost/users?fields=id,email` 将只返回 `id``email` 字段。
> Info: 你可能已经注意到了 `http://localhost/users` 的结果包括一些敏感字段,
> 信息:你可能已经注意到了 `http://localhost/users` 的结果包括一些敏感字段,
> 例如 `password_hash`, `auth_key` 你肯定不希望这些出现在你的 API 结果中。
> 你应该在 [响应格式](rest-response-formatting.md) 部分中过滤掉这些字段。

2
docs/guide-zh-CN/rest-resources.md

@ -90,7 +90,7 @@ public function fields()
}
```
> Warning: 模型的所有属性默认会被包含到API结果中,
> 警告:模型的所有属性默认会被包含到API结果中,
> 应检查数据确保没包含敏感数据,如果有敏感数据,
> 应覆盖`fields()`过滤掉,在上述例子中,我们选择过滤掉 `auth_key`,
> `password_hash``password_reset_token`.

2
docs/guide-zh-CN/rest-routing.md

@ -77,7 +77,7 @@
您可以通过设置 [[yii\rest\UrlRule::pluralize]] 为false 来禁用此行为,如果您想
使用一些特殊的名字您可以通过配置 [[yii\rest\UrlRule::controller]] 属性。
> Info: The pluralization of controller IDs is done by [[yii\helpers\Inflector::pluralize()]]. The method respects
> 信息:The pluralization of controller IDs is done by [[yii\helpers\Inflector::pluralize()]]. The method respects
special pluralization rules. For example, the word `box` will be pluralized as `boxes` instead of `boxs`.
In case when the automatic pluralization does not meet your requirement, you may also configure the

8
docs/guide-zh-CN/runtime-handling-errors.md

@ -66,7 +66,7 @@ throw new NotFoundHttpException();
错误处理器会显示异常以及详细的函数调用栈和源代码行数来帮助调试,
当`YII_DEBUG` 为 false,只有错误信息会被显示以防止应用的敏感信息泄漏。
> Info: 如果异常是继承 [[yii\base\UserException]],
> 信息:如果异常是继承 [[yii\base\UserException]],
不管`YII_DEBUG`为何值,函数调用栈信息都不会显示,
这是因为这种错误会被认为是用户产生的错误,开发人员不需要去修正。
@ -144,16 +144,16 @@ public function actionError()
* `exception`: 更多详细信息的异常对象,如HTTP 状态码,
错误码,错误调用栈等。
> Info: 如果你使用 [基础应用模板](start-installation.md) 或 [高级应用模板](tutorial-advanced-app.md),
> 注意:如果你使用 [基础应用模板](start-installation.md) 或 [高级应用模板](tutorial-advanced-app.md),
错误动作和错误视图已经定义好了。
> Note: If you need to redirect in an error handler, do it the following way:
> 注意:If you need to redirect in an error handler, do it the following way:
> ```php
> Yii::$app->getResponse()->redirect($url)->send();
> return;
> ```
> Note: If you need to redirect in an error handler, do it the following way:
> 注意:If you need to redirect in an error handler, do it the following way:
>
> ```php
> Yii::$app->getResponse()->redirect($url)->send();

8
docs/guide-zh-CN/runtime-responses.md

@ -73,7 +73,7 @@ $headers->set('Pragma', 'no-cache');
$values = $headers->remove('Pragma');
```
> Info: 头名称是大小写敏感的,在[[yii\web\Response::send()]]方法
> 信息:头名称是大小写敏感的,在[[yii\web\Response::send()]]方法
调用前新注册的头信息并不会发送给用户。
@ -152,7 +152,7 @@ public function actionInfo()
}
```
> Note: 如果创建你自己的响应对象,将不能在应用配置中设置 `response` 组件,尽管如此,
> 注意:如果创建你自己的响应对象,将不能在应用配置中设置 `response` 组件,尽管如此,
可使用 [依赖注入](concept-di-container.md)
应用通用配置到你新的响应对象。
@ -183,7 +183,7 @@ public function actionOld()
\Yii::$app->response->redirect('http://example.com/new', 301)->send();
```
> Info: [[yii\web\Response::redirect()]] 方法默认会设置响应状态码为302,该状态码会告诉浏览器请求的资源
> 信息:[[yii\web\Response::redirect()]] 方法默认会设置响应状态码为302,该状态码会告诉浏览器请求的资源
*临时* 放在另一个URI地址上,可传递一个301状态码告知浏览器请求
的资源已经 *永久* 重定向到新的URId地址。
@ -193,7 +193,7 @@ public function actionOld()
在客户端可编写JavaScript
代码读取该头部值然后让浏览器跳转对应的URL。
> Info: Yii 配备了一个`yii.js` JavaScript 文件提供常用JavaScript功能,
> 信息:Yii 配备了一个`yii.js` JavaScript 文件提供常用JavaScript功能,
包括基于`X-Redirect`头的浏览器跳转,
因此,如果你使用该JavaScript 文件(通过[[yii\web\YiiAsset]] 资源包注册),
就不需要编写AJAX跳转的代码。

20
docs/guide-zh-CN/runtime-routing.md

@ -124,7 +124,7 @@ With the above configuration, the `site/offline` action will be used to handle a
The `catchAll` property should take an array whose first element specifies a route, and
the rest of the elements (name-value pairs) specify the parameters to be [bound to the action](structure-controllers.md#action-parameters).
> Info: Debug panel on development environment will not work when this property is enabled
> 信息:Debug panel on development environment will not work when this property is enabled
## Creating URLs <span id="creating-urls"></span>
@ -266,7 +266,7 @@ The rest of the properties are optional. However, their configuration shown abov
URLs. It is the main property that you should work with in order to create URLs whose format satisfies your
particular application requirement.
> Note: In order to hide the entry script name in the created URLs, besides setting
> 注意:In order to hide the entry script name in the created URLs, besides setting
[[yii\web\UrlManager::showScriptName|showScriptName]] to be false, you may also need to configure your Web server
so that it can correctly identify which PHP script should be executed when a requested URL does not explicitly
specify one. If you are using Apache Web server, you may refer to the recommended configuration as described in the
@ -300,7 +300,7 @@ a parameter named `id`.
]
```
> Info: The pattern in a rule is used to match the path info part of a URL. For example, the path info of
> 信息:The pattern in a rule is used to match the path info part of a URL. For example, the path info of
`/index.php/post/100?source=ad` is `post/100` (the leading and ending slashes are ignored) which matches
the pattern `post/(\d+)`.
@ -331,7 +331,7 @@ of `<ParamName:RegExp>`, where `ParamName` specifies the parameter name and `Reg
expression used to match parameter values. If `RegExp` is not specified, it means the parameter value should be
a string without any slash.
> Note: You can only specify regular expressions for parameters. The rest part of a pattern is considered as plain text.
> 注意:You can only specify regular expressions for parameters. The rest part of a pattern is considered as plain text.
When a rule is used to parse a URL, it will fill the associated parameters with values matching the corresponding
parts of the URL, and these parameters will be made available in `$_GET` later by the `request` application component.
@ -389,7 +389,7 @@ be `comment` and `action` parameter to be `create`. The route `<controller>/<act
Similarly, to create a URL for the route `comment/index`, the third rule will apply, which creates a URL `/index.php/comments`.
> Info: By parameterizing routes, it is possible to greatly reduce the number of URL rules, which can significantly
> 信息:By parameterizing routes, it is possible to greatly reduce the number of URL rules, which can significantly
improve the performance of [[yii\web\UrlManager|URL manager]].
By default, all parameters declared in a rule are required. If a requested URL does not contain a particular parameter,
@ -474,9 +474,9 @@ the following in the application configuration:
The above configuration will allow the [[yii\web\UrlManager|URL manager]] to recognize requested URLs and also create
URLs with `.html` as their suffix.
> Tip: You may set `/` as the URL suffix so that the URLs all end with a slash.
> 提示:You may set `/` as the URL suffix so that the URLs all end with a slash.
> Note: When you configure a URL suffix, if a requested URL does not have the suffix, it will be considered as
> 注意:When you configure a URL suffix, if a requested URL does not have the suffix, it will be considered as
an unrecognized URL. This is a recommended practice for SEO (search engine optimization).
Sometimes you may want to use different suffixes for different URLs. This can be achieved by configuring the
@ -522,10 +522,10 @@ be parsed into `post/create`, while a request for `GET post/100` will be parsed
]
```
> Note: If a URL rule contains HTTP method(s) in its pattern, the rule will only be used for parsing purpose.
> 注意:If a URL rule contains HTTP method(s) in its pattern, the rule will only be used for parsing purpose.
It will be skipped when the [[yii\web\UrlManager|URL manager]] is called to create URLs.
> Tip: To simplify the routing of RESTful APIs, Yii provides a special URL rule class [[yii\rest\UrlRule]]
> 提示:To simplify the routing of RESTful APIs, Yii provides a special URL rule class [[yii\rest\UrlRule]]
which is very efficient and supports some fancy features such as automatic pluralization of controller IDs.
For more details, please refer to the [Routing](rest-routing.md) section about developing RESTful APIs.
@ -549,7 +549,7 @@ example is extracted from the [URL Suffixes](#url-suffixes) subsection,
]
```
> Info: By default if you do not specify the `class` option for a rule configuration, it will take the default
> 信息:By default if you do not specify the `class` option for a rule configuration, it will take the default
class [[yii\web\UrlRule]].

12
docs/guide-zh-CN/runtime-sessions-cookies.md

@ -69,7 +69,7 @@ foreach ($session as $name => $value) ...
foreach ($_SESSION as $name => $value) ...
```
> Info: 当使用`session`组件访问session数据时候,
> 信息:当使用`session`组件访问session数据时候,
如果session没有开启会自动开启,
这和通过`$_SESSION`不同,`$_SESSION`要求先执行`session_start()`。
@ -137,7 +137,7 @@ Yii提供以下session类实现不同的session存储方式:
所有这些session类支持相同的API方法集,因此,
切换到不同的session存储介质不需要修改项目使用session的代码。
> Note: 如果通过`$_SESSION`访问使用自定义存储介质的session,
> 注意:如果通过`$_SESSION`访问使用自定义存储介质的session,
需要确保session已经用[[yii\web\Session::open()]] 开启,
这是因为在该方法中注册自定义session存储处理器。
@ -174,7 +174,7 @@ CREATE TABLE session
- PostgreSQL: BYTEA
- MSSQL: BLOB
> Note: 根据 php.ini 设置的 `session.hash_function`,你需要调整`id`列的长度,
> 注意:根据 php.ini 设置的 `session.hash_function`,你需要调整`id`列的长度,
例如,如果 `session.hash_function=sha256`
应使用长度为64而不是40的char类型。
@ -255,7 +255,7 @@ $alerts = $session->getFlash('alerts');
会发现有时获取到一个数组,有时获取到一个字符串,
取决于你调用这两个方法的顺序。
> Tip: For displaying Flash messages you can use [[yii\bootstrap\Alert|bootstrap Alert]] widget in the following way:
> 提示:For displaying Flash messages you can use [[yii\bootstrap\Alert|bootstrap Alert]] widget in the following way:
>
> ```php
> echo Alert::widget([
@ -327,7 +327,7 @@ unset($cookies['language']);
[[yii\web\Cookie::domain|domain]], [[yii\web\Cookie::expire|expire]]
可配置这些属性到cookie中并添加到响应的cookie集合中。
> Note: 为安全起见[[yii\web\Cookie::httpOnly]] 被设置为true,
> 注意:为安全起见[[yii\web\Cookie::httpOnly]] 被设置为true,
这可减少客户端脚本访问受保护cookie(如果浏览器支持)的风险,
更多详情可阅读 [httpOnly wiki article](https://www.owasp.org/index.php/HttpOnly) for more details.
@ -340,7 +340,7 @@ unset($cookies['language']);
如果被修改,通过`request`组件的
[[yii\web\Request::cookies|cookie collection]]cookie集合访问不到该cookie。
> Note: Cookie验证只保护cookie值被修改,如果一个cookie验证失败,
> 注意:Cookie验证只保护cookie值被修改,如果一个cookie验证失败,
仍然可以通过`$_COOKIE`来访问该cookie,
因为这是第三方库对未通过cookie验证自定义的操作方式。

4
docs/guide-zh-CN/security-authorization.md

@ -227,7 +227,7 @@ return [
],
];
```
> Note: If you are using yii2-basic-app template, there is a `config/console.php` configuration file where the
> 注意:If you are using yii2-basic-app template, there is a `config/console.php` configuration file where the
`authManager` needs to be declared additionally to `config/web.php`.
> In case of yii2-advanced-app the `authManager` should be declared only once in `common/config/main.php`.
@ -303,7 +303,7 @@ class RbacController extends Controller
}
```
> Note: If you are using advanced template, you need to put your `RbacController` inside `console/controllers` directory
> 注意:If you are using advanced template, you need to put your `RbacController` inside `console/controllers` directory
and change namespace to `console/controllers`.
在用 `yii rbac/init` 执行了这个命令后,我们将得到下图所示的层次结构:

6
docs/guide-zh-CN/start-databases.md

@ -74,7 +74,7 @@ return [
上面配置的数据库连接可以在应用中通过 `Yii::$app->db` 表达式访问。
> Info: `config/db.php` 将被包含在应用配置文件 `config/web.php` 中,
> 信息:`config/db.php` 将被包含在应用配置文件 `config/web.php` 中,
后者指定了整个[应用](structure-applications.md)如何初始化。
请参考[配置](concept-configurations.md)章节了解更多信息。
@ -106,7 +106,7 @@ class Country extends ActiveRecord
这个 `Country` 类继承自 [[yii\db\ActiveRecord]]。你不用在里面写任何代码。
只需要像现在这样,Yii 就能根据类名去猜测对应的数据表名。
> Info: 如果类名和数据表名不能直接对应,
> 信息:如果类名和数据表名不能直接对应,
可以覆写 [[yii\db\ActiveRecord::tableName()|tableName()]] 方法去显式指定相关表名。
使用 `Country` 类可以很容易地操作 `country` 表数据,就像这段代码:
@ -128,7 +128,7 @@ $country->name = 'U.S.A.';
$country->save();
```
> Info: 活动记录是面向对象、功能强大的访问和操作数据库数据的方式。你可以在[活动记录](db-active-record.md)章节了解更多信息。
> 信息:活动记录是面向对象、功能强大的访问和操作数据库数据的方式。你可以在[活动记录](db-active-record.md)章节了解更多信息。
除此之外你还可以使用另一种更原生的被称做[数据访问对象](db-dao)的方法操作数据库数据。

10
docs/guide-zh-CN/start-forms.md

@ -48,7 +48,7 @@ class EntryForm extends Model
该类继承自Yii 提供的一个基类 [[yii\base\Model]],
该基类通常用来表示数据。
> Info: [[yii\base\Model]] 被用于普通模型类的父类并与数据表**无关**。[[yii\db\ActiveRecord]]
> 信息:[[yii\base\Model]] 被用于普通模型类的父类并与数据表**无关**。[[yii\db\ActiveRecord]]
通常是普通模型类的父类但与数据表有关联(译注:[[yii\db\ActiveRecord]] 类其实也是继承自 [[yii\base\Model]],增加了数据库处理)。
`EntryForm` 类包含 `name``email` 两个公共成员,
@ -119,7 +119,7 @@ class SiteController extends Controller
如果模型被成功填充数据(也就是说用户已经提交了 HTML 表单),
操作将调用 [[yii\base\Model::validate()|validate()]] 去确保用户提交的是有效数据。
> Info: 表达式 `Yii::$app` 代表[应用](structure-applications.md)实例,它是一个全局可访问的单例。
> 信息:表达式 `Yii::$app` 代表[应用](structure-applications.md)实例,它是一个全局可访问的单例。
同时它也是一个[服务定位器](concept-service-locator.md),
能提供 `request`,`response`,`db` 等等特定功能的组件。
在上面的代码里就是使用 `request` 组件来访问应用实例收到的 `$_POST` 数据。
@ -128,7 +128,7 @@ class SiteController extends Controller
如果没填表单就提交,或数据包含错误(译者:如 email 格式不对),
`entry` 视图将会渲染输出,连同表单一起输出的还有验证错误的详细信息。
> Note: 在这个简单例子里我们只是呈现了有效数据的确认页面。
> 注意:在这个简单例子里我们只是呈现了有效数据的确认页面。
实践中你应该考虑使用 [[yii\web\Controller::refresh()|refresh()]]
或 [[yii\web\Controller::redirect()|redirect()]] 去避免[表单重复提交问题](http://en.wikipedia.org/wiki/Post/Redirect/Get)。
@ -214,7 +214,7 @@ http://hostname/index.php?r=site/entry
如果用户浏览器禁用了 JavaScript,
服务器端仍然会像 `actionEntry()` 方法里这样验证一遍数据。这保证了任何情况下用户提交的数据都是有效的。
> Warning: 客户端验证是提高用户体验的手段。
> 警告:客户端验证是提高用户体验的手段。
无论它是否正常启用,服务端验证则都是必须的,请不要忽略它。
输入框的文字标签是 `field()` 方法生成的,内容就是模型中该数据的属性名。
@ -228,7 +228,7 @@ http://hostname/index.php?r=site/entry
<?= $form->field($model, 'email')->label('自定义 Email') ?>
```
> Info: Yii 提供了相当多类似的小部件去帮你生成复杂且动态的视图。
> 信息:Yii 提供了相当多类似的小部件去帮你生成复杂且动态的视图。
在后面你还会了解到自己写小部件是多么简单。
你可能会把自己的很多视图代码转化成小部件以提高重用,加快开发效率。

4
docs/guide-zh-CN/start-gii.md

@ -45,7 +45,7 @@ defined('YII_ENV') or define('YII_ENV', 'dev');
http://hostname/index.php?r=gii
```
> Info: 如果你通过本机以外的机器访问 Gii,请求会被出于安全原因拒绝。
> 信息:如果你通过本机以外的机器访问 Gii,请求会被出于安全原因拒绝。
> 你可以配置 Gii 为其添加允许访问的 IP 地址:
>
```php
@ -127,7 +127,7 @@ http://hostname/index.php?r=country/index
* 模型:`models/Country.php` 和 `models/CountrySearch.php`
* 视图:`views/country/*.php`
> Info: Gii 被设计成高度可定制和可扩展的代码生成工具。
> 信息:Gii 被设计成高度可定制和可扩展的代码生成工具。
使用它可以大幅提高应用开发速度。
请参考 [Gii](tool-gii.md) 章节了解更多内容。

4
docs/guide-zh-CN/start-hello.md

@ -22,7 +22,7 @@
从请求中接收 `message` 参数并显示给最终用户。
如果请求没有提供 `message` 参数,操作将显示默认参数 “Hello”。
> Info: [操作](structure-controllers.md#creating-actions)是最终用户可以直接访问并执行的对象。
> 信息:[操作](structure-controllers.md#creating-actions)是最终用户可以直接访问并执行的对象。
操作被组织在[控制器](structure-controllers.md)中。
一个操作的执行结果就是最终用户收到的响应内容。
@ -112,7 +112,7 @@ http://hostname/index.php?r=site/say&message=Hello+World
如果你省略 URL 中的 `message` 参数,将会看到页面只显示 “Hello”。
这是因为 `message` 被作为一个参数传给 `actionSay()` 方法,当省略它时,参数将使用默认的 `“Hello”` 代替。
> Info: 新页面和其它页面使用同样的头部和尾部是因为 [[yii\web\Controller::render()|render()]]
> 信息:新页面和其它页面使用同样的头部和尾部是因为 [[yii\web\Controller::render()|render()]]
方法会自动把 `say` 视图执行的结果嵌入称为[布局](structure-views.md#layouts)的文件中,
本例中是 `views/layouts/main.php`

2
docs/guide-zh-CN/structure-application-components.md

@ -45,7 +45,7 @@
]
```
> Info: 请谨慎注册太多应用组件,
> 信息:请谨慎注册太多应用组件,
应用组件就像全局变量,
使用太多可能加大测试和维护的难度。
一般情况下可以在需要时再创建本地组件。

6
docs/guide-zh-CN/structure-applications.md

@ -5,7 +5,7 @@
每个Yii应用系统只能包含一个应用主体,应用主体在
[入口脚本](structure-entry-scripts.md) 中创建并能通过表达式 `\Yii::$app` 全局范围内访问。
> Info: 当我们说"一个应用",它可能是一个应用主体对象,也可能是一个应用系统,
> 信息:当我们说"一个应用",它可能是一个应用主体对象,也可能是一个应用系统,
是根据上下文来决定[译:中文为避免歧义,Application翻译为应用主体]。
Yii有两种应用主体: [[yii\web\Application|网页应用主体]] and
@ -137,7 +137,7 @@ $config = require(__DIR__ . '/../config/web.php');
]
```
> Info: 如果模块 ID 和应用组件 ID 同名,优先使用应用组件 ID,
> 信息:如果模块 ID 和应用组件 ID 同名,优先使用应用组件 ID,
> 如果你想用模块 ID,
> 可以使用如下无名称函数返回模块 ID。
>
@ -192,7 +192,7 @@ if (YII_ENV_DEV) {
]
```
> Info: 当开启这个属性时,开发环境下的调试面板将不能工作。
> 信息:当开启这个属性时,开发环境下的调试面板将不能工作。
#### [[yii\base\Application::components|components]] <span id="components"></span>

24
docs/guide-zh-CN/structure-assets.md

@ -114,7 +114,7 @@ class AppAsset extends AssetBundle
由于它们的资源和源代码都在不能Web访问的目录下,
在定义资源包类时必须指定[[yii\web\AssetBundle::sourcePath|sourcePath]]属性。
> Note: [[yii\web\AssetBundle::sourcePath|source path]] 属性不要用`@webroot/assets`,该路径默认为
> 注意:[[yii\web\AssetBundle::sourcePath|source path]] 属性不要用`@webroot/assets`,该路径默认为
[[yii\web\AssetManager|asset manager]]资源管理器将源资源发布后存储资源的路径,
该路径的所有内容会认为是临时文件,
可能会被删除。
@ -142,7 +142,7 @@ class AppAsset extends AssetBundle
这些属性值会分别传递给 [[yii\web\View::registerCssFile()]] 和 [[yii\web\View::registerJsFile()]] 方法,
在[视图](structure-views.md) 调用这些方法包含CSS和JavaScript文件时。
> Note: 在资源包类中设置的选项会应用到该包中 *每个* CSS/JavaScript 文件,
> 注意:在资源包类中设置的选项会应用到该包中 *每个* CSS/JavaScript 文件,
如果想对每个文件使用不同的选项,
应创建不同的资源包并在每个包中使用一个选项集。
@ -216,7 +216,7 @@ the `only` publishing option, only the `fonts` and `css` subdirectories will be
应设置 [[yii\web\AssetBundle::sourcePath|sourcePath]] 属性为`@bower/PackageName` 或 `@npm/PackageName`
因为根据别名Composer会安装Bower或NPM包到对应的目录下。
> Note: 一些包会将它们分布式文件放到一个子目录中,对于这种情况,应指定子目录作为
> 注意:一些包会将它们分布式文件放到一个子目录中,对于这种情况,应指定子目录作为
[[yii\web\AssetBundle::sourcePath|sourcePath]]属性值,
例如,[[yii\web\JqueryAsset]]使用 `@bower/jquery/dist` 而不是 `@bower/jquery`
@ -231,7 +231,7 @@ use app\assets\AppAsset;
AppAsset::register($this); // $this 代表视图对象
```
> Info: The [[yii\web\AssetBundle::register()]] method returns an asset bundle object containing the information
> 信息:The [[yii\web\AssetBundle::register()]] method returns an asset bundle object containing the information
about the published assets, such as [[yii\web\AssetBundle::basePath|basePath]] or [[yii\web\AssetBundle::baseUrl|baseUrl]].
如果在其他地方注册资源包,应提供视图对象,如在 [小部件](structure-widgets.md) 类中注册资源包,
@ -275,7 +275,7 @@ return [
数组的键应为资源包的类名(最开头不要反斜杠),
数组的值为对应的[配置数组](concept-configurations.md).
> Tip: 可以根据条件判断使用哪个资源,如下示例为如何在开发环境用`jquery.js`,
> 提示:可以根据条件判断使用哪个资源,如下示例为如何在开发环境用`jquery.js`,
> 否则用`jquery.min.js`:
>
> ```php
@ -334,7 +334,7 @@ return [
(如果有的话前缀为 [[yii\web\AssetBundle::sourcePath]]),对应的值为替换原来的资源。
例如,资源文件`my/path/to/jquery.js` 匹配键 `jquery.js`.
> Note: 只有相对相对路径指定的资源对应到资源部署,替换的资源路径可以为绝对路径,
> 注意:只有相对相对路径指定的资源对应到资源部署,替换的资源路径可以为绝对路径,
也可为和[[yii\web\AssetManager::basePath]]相关的路径。
@ -476,7 +476,7 @@ return [
数组的值为目标资源文件扩展名和执行资源转换的命令,
命令中的标记 `{from}` 和`{to}`会分别被源资源文件路径和目标资源文件路径替代。
> Info: 除了以上方式,也有其他的方式来处理扩展语法资源,
> 信息:除了以上方式,也有其他的方式来处理扩展语法资源,
例如,可使用编译工具如[grunt](http://gruntjs.com/)
来监控并自动转换扩展语法资源,此时,
应使用资源包中编译后的CSS/Javascript文件而不是原始文件。
@ -488,7 +488,7 @@ return [
通常的方式是在页面中合并并压缩多个CSS/JavaScript 文件为一个或很少的几个文件,
并使用压缩后的文件而不是原始文件。
> Info: 合并和压缩资源通常在应用在产品上线模式,
> 信息:合并和压缩资源通常在应用在产品上线模式,
在开发模式下使用原始的CSS/JavaScript更方便调试。
接下来介绍一种合并和压缩资源文件
@ -522,7 +522,7 @@ return [
已合并的CSS和Javascipt文件会更大,因此会增加文件传输时间,在这个示例中,
我们使用第一种方式,也就是用一个组包含所有包。
> Info: 将资源包分组并不是无价值的,通常要求分析现实中不同页面各种资源的数据量,
> 信息:将资源包分组并不是无价值的,通常要求分析现实中不同页面各种资源的数据量,
开始时为简便使用一个组。
在所有包中使用工具(例如 [Closure Compiler](https://developers.google.com/closure/compiler/),
@ -635,7 +635,7 @@ return [
在`targets`选项中应指定这些包如何分组,
如前述的可以指定一个或多个组。
> Note: 由于在控制台应用别名 `@webroot` and `@web` 不可用,
> 注意:由于在控制台应用别名 `@webroot` and `@web` 不可用,
应在配置中明确指定它们。
JavaScript文件会被合并压缩后写入到`js/all-{hash}.js`文件,
@ -658,7 +658,7 @@ yii asset assets.php config/assets-prod.php
如最后一小节所描述的。
> Info: 使用`asset` 命令并不是唯一一种自动合并和压缩过程的方法,
> 信息:使用`asset` 命令并不是唯一一种自动合并和压缩过程的方法,
可使用优秀的工具[grunt](http://gruntjs.com/)来完成这个过程。
@ -710,5 +710,5 @@ As you can see, the asset bundles are divided into three groups: `allShared`, `a
They each depends on an appropriate set of asset bundles. For example, `allBackEnd` depends on `app\assets\AdminAsset`.
When running `asset` command with this configuration, it will combine asset bundles according to the above specification.
> Info: You may leave the `depends` configuration empty for one of the target bundle. By doing so, that particular
> 信息:You may leave the `depends` configuration empty for one of the target bundle. By doing so, that particular
asset bundle will depend on all of the remaining asset bundles that other target bundles do not depend on.

4
docs/guide-zh-CN/structure-controllers.md

@ -144,7 +144,7 @@ class SiteController extends Controller
为`@app/controllers/ArticleController.php`的文件中定义,
控制器`admin/post-comment`应在`@app/controllers/admin/PostCommentController.php`文件中。
> Info: 最后一个示例 `admin/post-comment` 表示你可以将控制器放在
> 信息:最后一个示例 `admin/post-comment` 表示你可以将控制器放在
[[yii\base\Application::controllerNamespace|controller namespace]]控制器命名空间下的子目录中,
在你不想用 [模块](structure-modules.md) 的情况下给控制器分类,这种方式很有用。
@ -244,7 +244,7 @@ class SiteController extends Controller
例如`index` 转成 `actionIndex`, `hello-world` 转成 `actionHelloWorld`
> Note: 操作方法的名字*大小写敏感*,如果方法名称为`ActionIndex`不会认为是操作方法,
> 注意:操作方法的名字*大小写敏感*,如果方法名称为`ActionIndex`不会认为是操作方法,
所以请求`index`操作会返回一个异常,
也要注意操作方法必须是公有的,
私有或者受保护的方法不能定义成内联操作。

2
docs/guide-zh-CN/structure-filters.md

@ -224,7 +224,7 @@ use yii\web\Response;
];
```
> Info: 如果请求中没有检测到内容格式和语言,
> 信息:如果请求中没有检测到内容格式和语言,
使用[[formats]]和[[languages]]第一个配置项。

10
docs/guide-zh-CN/structure-models.md

@ -17,7 +17,7 @@
`Model` 类也是更多高级模型如[Active Record 活动记录](db-active-record.md)的基类,
更多关于这些高级模型的详情请参考相关手册。
> Info: 模型并不强制一定要继承[[yii\base\Model]],但是由于很多组件支持[[yii\base\Model]],
> 信息:模型并不强制一定要继承[[yii\base\Model]],但是由于很多组件支持[[yii\base\Model]],
最好使用它做为模型基类。
@ -147,7 +147,7 @@ public function attributeLabels()
甚至可以根据条件定义标签,例如通过使用模型的 [scenario场景](#scenarios),
可对相同的属性返回不同的标签。
> Info: 属性标签是 [视图](structure-views.md)一部分,
> 信息:属性标签是 [视图](structure-views.md)一部分,
但是在模型中申明标签通常非常方便,并可行程非常简洁可重用代码。
@ -195,7 +195,7 @@ class User extends ActiveRecord
}
```
> Info: 在上述和下述的例子中,模型类都是继承[[yii\db\ActiveRecord]],
> 信息:在上述和下述的例子中,模型类都是继承[[yii\db\ActiveRecord]],
因为多场景的使用通常发生在[Active Record](db-active-record.md) 类中.
`scenarios()` 方法返回一个数组,数组的键为场景名,值为对应的 *active attributes活动属性*
@ -345,7 +345,7 @@ public function scenarios()
}
```
> Info: 块赋值只应用在安全属性上,
> 信息:块赋值只应用在安全属性上,
因为你想控制哪些属性会被终端用户输入数据所修改,
例如,如果 `User` 模型有一个`permission`属性对应用户的权限,
你可能只想让这个属性在后台界面被管理员修改。
@ -490,7 +490,7 @@ public function fields()
}
```
> Warning: 由于模型的所有属性会被包含在导出数组,最好检查数据确保没包含敏感数据,
> 警告:由于模型的所有属性会被包含在导出数组,最好检查数据确保没包含敏感数据,
> 如果有敏感数据,应覆盖 `fields()` 方法过滤掉,
> 在上述列子中,我们选择过滤掉
> `auth_key`, `password_hash` and `password_reset_token`

4
docs/guide-zh-CN/structure-modules.md

@ -191,7 +191,7 @@ $module = MyModuleClass::getInstance();
如果模块没有被请求,该方法会返回空,注意不需要手动创建一个模块类,
因为手动创建的和Yii处理请求时自动创建的不同。
> Info: 当开发模块时,你不能假定模块使用固定的ID,
> 信息:当开发模块时,你不能假定模块使用固定的ID,
因为在应用或其他没模块中,模块可能会对应到任意的ID,
为了获取模块ID,应使用上述代码获取模块实例,
然后通过`$module->id`获取模块ID。
@ -265,7 +265,7 @@ class Module extends \yii\base\Module
例如`forum/admin/dashboard/index` 代表
在模块`forum`中子模块`admin`中`dashboard`控制器的`index`操作。
> Info: The [[yii\base\Module::getModule()|getModule()]] method only returns the child module directly belonging
> 信息:The [[yii\base\Module::getModule()|getModule()]] method only returns the child module directly belonging
to its parent. The [[yii\base\Application::loadedModules]] property keeps a list of loaded modules, including both
direct children and nested ones, indexed by their class names.

2
docs/guide-zh-CN/structure-views.md

@ -44,7 +44,7 @@ $this->title = 'Login';
这些变量代表从[控制器](structure-controllers.md)
或其他触发[视图渲染](#rendering-views)的对象 *传入* 到视图的数据。
> Tip: 将预定义变量列到视图文件头部注释处,
> 提示:将预定义变量列到视图文件头部注释处,
这样可被IDE编辑器识别,也是生成视图文档的好方法。

4
docs/guide-zh-CN/structure-widgets.md

@ -67,7 +67,7 @@ use yii\helpers\Html;
注意和调用 [[yii\base\Widget::widget()]] 返回渲染结果不同,
调用 [[yii\base\Widget::begin()]] 方法返回一个可组建小部件内容的小部件实例。
> Note: 当调用 [[yii\base\Widget::end()]] 的时候,一些小部件将使用 [输出缓冲](http://php.net/manual/en/book.outcontrol.php)
> 注意:当调用 [[yii\base\Widget::end()]] 的时候,一些小部件将使用 [输出缓冲](http://php.net/manual/en/book.outcontrol.php)
> 来调整封闭的内容。因此,当调用 [[yii\base\Widget::begin()]] 和
> [[yii\base\Widget::end()]] 时,最好在同一个视图文件里。
> 不遵循这个规则可能会导致意外的输出。
@ -155,7 +155,7 @@ class HelloWidget extends Widget
如上所示,PHP输出缓冲在`init()`启动,所有在`init()`
`run()`方法之间的输出内容都会被获取,并在`run()`处理和返回。
> Info: 当你调用 [[yii\base\Widget::begin()]] 时会创建一个新的小部件
> 信息:当你调用 [[yii\base\Widget::begin()]] 时会创建一个新的小部件
实例并在构造结束时调用`init()`方法,
在`end()`时会调用`run()`方法并输出返回结果。

2
docs/guide-zh-CN/test-environment-setup.md

@ -42,7 +42,7 @@ Changed current directory to <directory>
然后,将 `<directory>/vendor/bin` 增加到你的 `PATH` 环境变量中。现在,
我们可以在命令行中全局的使用 `codecept` 命令了。
> Note: global installation allows you use Codeception for all projects you are working on your development machine and
> 注意:global installation allows you use Codeception for all projects you are working on your development machine and
allows running `codecept` shell command globally without specifying path. However, such approach may be inappropriate,
for example, if 2 different projects require different versions of Codeception installed.
For the simplicity all shell commands related to the tests running around this guide are written assuming Codeception

4
docs/guide-zh-CN/tutorial-i18n.md

@ -191,7 +191,7 @@ short form: {PlaceholderName, ParameterType}
full form: {PlaceholderName, ParameterType, ParameterStyle}
```
> Note: If you need to use special characters such as `{`, `}`, `'`, `#`, wrap them in `'`:
> 注意:If you need to use special characters such as `{`, `}`, `'`, `#`, wrap them in `'`:
>
```php
echo Yii::t('app', "Example of string with ''-escaped characters'': '{' '}' '{test}' {count,plural,other{''count'' value is # '#{}'}}", ['count' => 3]);
@ -369,7 +369,7 @@ echo \Yii::t('app', 'There {n, plural, =0{are no cats} =1{is one cat} other{are
而不是一个原始消息,除非设置应用程序的
[[yii\base\Application::$sourceLanguage|源语言]] 为 `ru-RU`
> Note: The above example Russian message is mainly used as a translated message, not an original message, unless you set
> 注意:The above example Russian message is mainly used as a translated message, not an original message, unless you set
> the [[yii\base\Application::$sourceLanguage|source language]] of your application as `ru-RU` and translating from Russian.
>
> When a translation is not found for an original message specified in `Yii::t()` call, the plural rules for the

2
docs/guide-zh-CN/tutorial-yii-integration.md

@ -126,7 +126,7 @@ new yii\web\Application($yiiConfig); // 千万别在这调用 run() 方法。(
不必用 Yii 2 重写整个应用,你也可以通过增添对哪些
Yii 2 独占功能的支持来增强这个系统。下面我们就来详细描述一下具体的实现过程。
> Note: Yii 2 需要 PHP 5.4+ 的版本。你需要确保你的服务器以及现有应用都
> 注意:Yii 2 需要 PHP 5.4+ 的版本。你需要确保你的服务器以及现有应用都
> 可以支持 PHP 5.4。
首先,参考前文板块中给出的方法,在已有的应用中安装 Yii 2。

Loading…
Cancel
Save