Hi there,
I'm building an app that supports various languages.
File Translation in the context of a "render-call" works well via findLocalizedFile()
The question:
How do I load the main.php for the correct language??
My folder structure is a suggested by Yii:
themes/themeName/views/layouts/main.php
themes/themeName/views/layouts/en/main.php
Thx
Andreas
Page 1 of 1
Load Language Dependent Main.php ?
#2
Posted 20 January 2013 - 01:27 PM
Dear Friend
You can use the Controller.php in components folder.
Normally all the controllers are derived from it,if you have not changed default things.
components/Controller.php
We can also declare them in a function in an application behavior and then you can attach that function to
"onBeginRequest" of the application.
Regards.
You can use the Controller.php in components folder.
Normally all the controllers are derived from it,if you have not changed default things.
components/Controller.php
class Controller extends CController
{
public function init()
{
if(Yii::app()->language=="aa")
Yii::app()->theme="theme1";
if(Yii::app()->language=="ru")
Yii::app()->theme="theme2";
if(Yii::app()->language=="en_us")
Yii::app()->theme="theme3";
}
}
We can also declare them in a function in an application behavior and then you can attach that function to
"onBeginRequest" of the application.
Regards.
#3
Posted 20 January 2013 - 02:07 PM
Ah ok...
Just found the answer myself.
Actually findLocalizedFile() is called within the render()-method itself.
So no need to worry about file translation at all.. its done automatically as long as the correct language is set and the files in the view folders are present.
The only important part is that you stick to this structure:
Just found the answer myself.
Actually findLocalizedFile() is called within the render()-method itself.
So no need to worry about file translation at all.. its done automatically as long as the correct language is set and the files in the view folders are present.
The only important part is that you stick to this structure:
themes/themeName/views/layouts/main.php themes/themeName/views/layouts/en/main.php
#4
Posted 20 January 2013 - 02:25 PM
Sorry Friend!
I misunderstood that you needed different layouts under separate themes for different languages.
I misunderstood that you needed different layouts under separate themes for different languages.
Share this topic:
Page 1 of 1

Help













