Code Add Location:
Add the following within the config->main.php return of the project file directory and set the en-US and ZH-CN folders in the new messages in the project directory. Create a lang.php Language conversion array in the ZH-CN folder, and set up the relevant language conversion content, when you want to do language conversion in any place, in <?php?> declaration " \yii:: $app->language = ' ZH-CN '; Change the language ", and then use this, for example:" ' label ' = + yii::t (' lang ', ' Home ') ".
main.php
' Language ' = ' en-US ',//Add this sentence default language' i18n ' = [ ' Translations ' = [ ' lang* ' = [ ' Class ' = ' Yii\i18n\phpmessagesource ',//saving information using PHP files' BasePath ' = ' @app/messages ',//PHP File Save location//' sourcelanguage ' = ' en ',' Filemap ' = [ ' lang ' = ' lang.php ', ' lang/error ' = ' error.php ', ], ], ], ],
lang.php
<? PHP return [ ' home ' = ' homepage ', ];
The problem of Yii2 internationalization ZH-CN