How To Change The Layout Of The Theme On Language Change

I am working on a multilangual site, in which I have implements 2 languages i.e. Arabic and English.

But I want that when I select the Arabic language then the layout of the theme should be from right-to-left and when select english language then the layout should change to left-to-right.

I have created the right-to-left and left-to-right layouts of the theme, but I am cunfused that How can I implement this ?

Any idea about this ?

Thanks in advance.

There is $layout property in CController, that holds “the name of the layout to be applied to this controller’s views”. This what U should use to switch between layouts.

Simple solution would be to check language on beforeAction or beforeRender, something like:

public function beforeRender($view)

{

if ($language == arabic )

   $this->layout = 'arabic_layout';

else if ($language == ‘english’)

   $this->layout = 'english_layout';

retrun parent::beforeRender($view);

}

You can also do this in your layout file by including the actual layout file there.

Something like:




$layout='./mylayout_';

$layout_default=$layout.'default.php';

$layout_lang=$layout.Yii::app()->getLanguage().'.php';

if(file_exists($layout_lang)) {

   include($layout_lang);

} else {

   include($layout_default);

}



you can get an idea from this tutorial -

http://www.dukaweb.net/2014/04/simple-way-to-make-yii-multi-language-website.html

Dear I have already implement the multilangual system, but I want to change the layout of the site from L-R or R-L when select a particular language.