yii 国际化

http://www.yiichina.com/doc/guide/2.0/tutorial-i18n

config/main.php  

  外层加

'language' => 'en-US',
'sourceLanguage' => 'zh-CN',
components里加
'i18n' => [
            'translations' => [
                '*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    //'basePath' => '/messages',
                    'fileMap' => [
                        'collection' => 'collection.php'
                    ],
                ],
            ],
        ],

  

简单使用

Yii::t('app', 'This is a string to translate!');

  

config同级目录下建messages目录

 

posted @ 2018-06-06 12:21  程序生(Codey)  阅读(244)  评论(0编辑  收藏  举报