Implement internationalization support for attribute tags in Yii 2.0
1. Because some public models are generated into the common directory, and multiple database connection components are configured, for KCU The models of the CDB are prefixed with kcuc to prevent naming conflicts (otherwise, the model name is not recommended with the corresponding table prefix), as shown in Figure 1:
2. Use table prefix: use the table prefix to be checked; generate labels from db comments: The label is not checked based on the DB annotation (because it will be manually translated later); enable I18N: To enable internationalization to be checked; message Category: The information classification is set to CommonAttributeLabels/KcucMembers, which is the category used by yi::t() when internationalization is enabled, for the attribute tags under the current model class, as shown in Figure 2 after generation:

Generate Labels from DB comments: The labels are not checked based on the DB annotation (because manual translation processing is required in the later stage)
3. In the application, follow the following code to configure the message translation, as shown in Figure 3:
The pattern commonAttributeLabels* means that all message categories starting with CommonAttributeLabels use this translated source.
The pattern attributeLabels* means that all message category names starting with AttributeLabels use this translated source. Its root path is the current application.
Mode * indicates the specified default translation. Its root path is the current application.
4. Create new\Common\Messages\zh-CN\CommonattributeLabels\KCUCMember s.php, \common\messages\zh-cn\not_specified_category.php, as shown in Figure 4:

Create new\Common\Messages\zh-CN\CommonattributeLabels\KcucMembe rs.php, \common\messages\zh-cn\not_specified_category.php
5. Edit \Common\Messages\zh-CN\CommonattributeLabels\kcucMembers.php, as shown in Figure 5:
6. Tips: You can check the Generate Labels from DB Comments under zh-CN, and copy the public function under the model class when preview AttributeLabels(), re-edited, as shown in Figure 6;

Tips: You can check Generate Labels from DB Comments under zh-CN, copy the public function attributeLabels() under the model class during preview, and then edit
7. Test,
$model = new \common\models\kcucmembers;
// display as “mobile”
echo $model->GetAttributeLabel(mobile);
default[[yii\base\Application::$sourceLanguage|源语言]] value is EN-US, that is, American English, remain the same, if[[yii\base\Application::$language|目标语言]] is not set, or set to EN-US, then
Print out “Mobile”, as shown in Figure 7:
Print out the “user mobile phone”, as shown in Figure 8:



![如果[[yii\base\Application::$language|目标语言]]未设置,或者设置为en-US,则 打印出"Mobile"](https://www.shuijingwanwq.com/wp-content/uploads/2016/06/7.png)
![如果[[yii\base\Application::$language|目标语言]]设置为zh-CN,则 打印出"用户手机"](https://www.shuijingwanwq.com/wp-content/uploads/2016/06/8.png)