国际化功能一般很少用到,但作为学习,还是有必要接触一下。
国际化最常用到的方法是\Yii::t,官方文档如下
Translates a message to the specified language.
This is a shortcut method of yii\i18n\I18N::translate().
The translation will be conducted according to the message category and the target language will be used.
You can add parameters to a translation message that will be substituted with the corresponding value after translation. The format for this is to use curly brackets around the parameter name as you can see in the following example:
$username = 'Alexander';
echo \Yii::t('app', 'Hello, {username}!', ['username' => $username]);
Further formatting of message parameters is supported using the PHP intl extensions message formatter. See yii\i18n\I18N::translate() for more details.