Mid page sourceLanguage change

I am trying change the sourceLanguage in the Yii app to french half way through rendering the page


Yii::app()->sourceLanguage = 'fr';

I am using a sandbox controller for general testing and this is the actionChangeLang function:




        $message = 'This string will be translated to french.';


        echo Yii::t('multi', $message);

        echo "<br>";

        Yii::app()->sourceLanguage = 'fr';

        echo "<br>";

        echo Yii::t('multi', $message);

        Yii::app()->sourceLanguage = 'en_us';



The resulting page looks like this:

I have also tried:




echo Yii::t('multi', $message, null, null, 'fr');



My DB is set up correctly and translations work on all other pages. It is just when I try and change the language half way through the page.

Any help would be greatly appreciated!

Try this


echo Yii::t('multi', $message, array(), null, 'fr');