language definition

Hi!

I have a problem with language definition in my Yii application.

I want enable the user to choise the language (frrench and english).

In my config/main.php I have :


'sourceLanguage'=>'en_us'

and


'language'=>'en_us'

I have an action in SiteController which is executed when the user whant to change the application language :




/*

         * Set the user language

         */

        public function actionSetLanguage($language){

            Yii::app()->setLanguage($language);

            $this->redirect(Yii::app()->homeUrl);

        }



In my view/site/index.php which correspond to homeUrl, i have done :


echo Yii::app()->getLanguage();

.

It displays ‘en_us’ even if I despite the fact that i call actionSetLanguage(‘fr_fr’).

What could be the problem?

Thanks for your help.

The application is terminated after the redirect, so is the language setting. The client performs a new request to homeUrl which instantiates a new application with the default language values.

Remember: No state in HTTP. Persist the chosen language in db or session.

HTH,

– David

Take a look here