I am trying to setup internationalization for a web app. A user can specify his default language. the app is suppose to pick this up and render in the language chose.
I am setting the default language in the user controller and then saving it to a session variable --> for testing purposes. I then set
When i render the site/index view, after login i get proper french labels and text.
echo yii::app()->user->language; -----> set to fr_ca
echo yii::app()->language; -----> set to fr_ca also
echo '<h5>';
echo Yii::t('app','Projects'); -----> this shows the proper french text.
echo '</h5>';
As soon as i navigate to another view, like projects, i get a different result:
<?php
echo yii::app()->user->language; ------> is still set to fr_ca
echo yii::app()->language; ------> is now set to en_ca
?>
Why would Yii::app()->language be set to another value?
I have set the default language in the main config file to ‘sourceLanguage’=>‘en_us’.
Are you saying that i have to set it everytime i call an action? If so, then i must ensure that i run this code in a method that is common to every possible action?
I thought, once it was set it would remain. Odd. This is not something i read in the internationalization documentation.
The only thing that is said about it is this: "One can configure target language in the application configuration, or change it dynamically before any internationalization occurs."