Yii: GetText _() vs Yii::t()

前端 未结 4 1102
温柔的废话
温柔的废话 2021-01-21 18:32

When translating strings in Yii with GetText, do we have to use Yii::t($category,\'message\') or gettext\'s _(\'message\') syntax?

And then how

4条回答
  •  一整个雨季
    2021-01-21 19:19

    You need to use Yii::t() for translations. with the inbuilt yiic message command you can generate all the text in to language file.

    Example-

     Yii::t('app', 'Hello World');
     Yii::t('email', 'Welcome');
    

    This will generate 2 files app.php and email.php inside your messages directory. messages/en/app.php & messages/en/email.php

    please find more info about Yii translations here

    https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n https://www.yiiframework.com/doc/guide/1.1/en/topics.i18n

提交回复
热议问题