search

Home  >  Q&A  >  body text

php - yii2.0 language pack problem

I built a Chinese language package in frontend>messages, why can’t it be used in the form model in frontend>model? 'id'=> Yii::t('common','ID'), says Yii is an undefined class? Please God, what is going on?

This is the code for the language pack:

return [
    'Blog'=>'博客',
    'Article'=>'文章',
    'Signup'=>'注册',
    'Login'=>'登录',
    'Email' => '邮箱',
    'artTitle'=> '文章标题',
];

This is the calling code:

public function attributeLabels()
    {
        return [
            //'id'=> Yii::t('common','ID'),
            //'id' => '编码',
            //'title' => '标题',
            'title' => yii::t('common','artTitle'),
            'content' => '内容',
            'label_img' =>'标签图',
            'tags' => '标签',
            'cat_id'=>'分类'
        ];
    }

yii said it is an undefined class~
Please give me some guidance on how to modify it

淡淡烟草味淡淡烟草味2757 days ago699

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-06-06 09:55:46

    If you do not use Yii, you need Yii:t() to indicate that you are searching in the root namespace.

    reply
    0
  • Cancelreply