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

前端 未结 4 1154
温柔的废话
温柔的废话 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:10

    I use it like this:

    when i have for example:

    Yii::app()->language = en
    

    in folder messages have I folder en and on this folder I have file lang.php

    on this folder lang.php I have for example:

    'search',
            'example2'=>'news',
        );
    

    then when i need call view translate:

    
    

    and result is: search


    when I change: Yii::app()->language = de, I must have messages/de/lang.php and on this foler I have:

    'Suche',
            'example2'=>'Nachrichten',
        );
    

    then when i need call view translate:

    
    

    result is: Suche

提交回复
热议问题