Yii Translation Not Working

For the life of me, I am unable to get Yii’s translation working and I’ve followed the instructions in the documentation and forums very closely. Hope someone can enlighten me…

I just want to setup a bilingual site in Yii that is English and Chinese, so I added the following to config/main.php



Next, I created a file called dict.php under protected/messages/zh_cn/

The contents of this file is as follows:


return array(

	'home'=>'Home (in chinese)',

	'about'=>'About Us (in chinese)',


Then in my view, I have this:

<?=Yii::t('dict', 'home')?>

Which consistently displays "home" instead of "Home (in chinese)".

I have tried searching all over the forums and have tried all kinds of ways of setting this, but nothing seems to be working. Yii just is unable to display the chinese text no matter what I do.

Am I missing something? Is there an additional step I have overlooked? Help! I am really not sure what else to do at this point, I’ve followed all the instructions in the documentation but cannot get this to work. This is driving me crazy! I cannot believe such a simple concept is so difficult to execute in Yii, well at least the documentation isn’t the best regarding this.

Help me Obi-wan, you’re my only hope… well you or CodeIgniter, which I am seriously considering falling back to if Yii continues to be so difficult to work with.



you are code



said that sourceLanguage is Chinese --> the key element of array.

if you change sourceLanguage :


all work like you want.



add this in your config under appname



and make sure your dict filename under zh_cn match the Yii::t’s first parameter for example in your case


in your dict.php


return array(

   'home'=>'chinese homepage'


he just posted an answer I was typing damn sorry

Thanks, that fixed the problem.

Wow! Yii’s documentation is pretty terrible. I wish the documentation provided more sample code instead of just descriptive text, especially the API docs. The concept of source language vs target language is not explained clearly at all in the I18N docs, and did not give me any indication on how to set up bilingual site.

Will keep learning, but so far I am really disappointed with Yii’s documentation. Seriously, why aren’t there more code samples inside the API docs?? For example, in the CHtml::ajaxButton section of API docs, there is the following entry:

Seriously? How the hell am I supposed to figure out what variables and arrays and var names I can use within the $htmlOptions array. This is by far THE MOST FRUSTRATING thing about Yii’s documentation.

Outside of that, I do like Yii.

hey stinkytofu contact me if you interested we can start an unofficial fork of docs I had similar issues when i first started but that was long ago 2010 I wanna do something for new commers

Reading The Yii Book helped me a great deal. Maybe you should consider buying it too?