[SOLVED] What does 'category' mean in Yii::t() ?

Hey, guys, I've just read the documentation for error handling using controller/action and now I'm trying to find a way to show the error messages translated.

I know I should do something like this:


    echo ‘Erro ‘, $code , ’ - ’ , Yii::t(’????’,$message);


But I couldn't understand the $category parameter in Yii::t($category, $message).

the documentation didn't help me in this case, so, could anybody please give me a hint?

thanks a lot!!!


As I understand, a category is used for your convenience to group messages in a context, which will server as message filename as well.

Here is a quote from the class references:

Translations in one language are kept as PHP files under an individual subdirectory whose name is the same as the language ID. Each PHP file contains messages belonging to the same category, and the file name is the same as the category name.

thanks Will, but now I have a file/category named error.php, in the same directory as yii.php file (protected/messages/pt_br/), which contains:


return array (

  'Message'=>'Another Message',


and I'm using a controller/view error handler:

    public function actionerror()



            $this->render('error', $error);


My view site/error is:



    echo 'Erro ', $code , ' - ' , Yii::t('error','Message');



The content is renderized fine, but the message is not translated.

If I add the same translation to the yii.php file I mentioned above, the message is translated .

What I'm doing wrong?


Did you set your application's language property to be pt_br?

You've to set the language in each controller you want to use Yii::t('','')…

fighted with the same fault yesterday :)

see: http://www.yiiframew…pic,2648.0.html

my config/main.php

return array(


// preloading &#039;log&#039; component


// autoloading model and component classes







my site controller:

class SiteController extends CController


    public function init(){



still if I put the message in yii.php file under protected/messages/pt_br and set the view to display


the translated message is shown, but with my error.php file it doesn't work.

I made a copy/paste of yii.php and changed the content because I thought it could be a matter of encoding, but no postiive results yet…

your help guys is very appreciated, thanks again!



must be:


it is a -  not a _

thank you very much guys, you're great!!!