How to translate site name and company name


Does anyone know how to use Yii::t() to translate website site name and company name in the main config?

$config = array(

'name' => 'my site name',

'params' => array(

    'companyName' => 'my company name',


There are some solutions. For example, put name in your config file as is:

return array('name' => 'My Site Name');

Create helper function in your base class:

public static function getSiteName()


    return Yii::t('category', Yii::app()->name);


In all of your view files use:

<?php echo CHtml::encode(YourBaseClass::getSiteName()); ?>

Hi, I use Yii::t() in all the views which is similar to ur solution 2.

for the solution 1, it could only set the ‘name’ but cannot use t() in the config.


There are no two solutions in my post. It is one solution.