Setting language

I successfully changed the language for my Yii application to portuguese by changing the main.php and adding:


However strangely when i look at the source of the generated pages at the header this is what i get

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http_//">

<html xmlns="http_//" xml:lang="en" lang="en">


	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<meta name="language" content="en" />

Also when displaying zii.widgets.grid.CGridView widget i get the pagination messages in english.

What should i do more ?

PS: I changed the : in the URL otherwise i couldn’t post.

Hi Artur,

the HTML is defined in the layout used by your application. Take a look at the folder protected/views/layouts. If you are using the webapp created by Yii command line tool, you should find a file called main.html there. This is the main HTML layout, and as you can see, the <meta> language element is hard coded (same for the 'lang attribute).

You should make it dynamic, something like :


  &lt;html xmlns=&quot;http_//; 

           	xml:lang=&quot;&lt;?php echo Yii::app()-&gt;language; ?&gt;&quot; 

              lang=&quot;&lt;?php echo Yii::app()-&gt;language; ?&quot;&gt;


Hope this helps