I’d like to set the language of my application (i18n) according to the user profile but it doesn’t work. In the following excerpt, the profile is right and is stored in an array.
In UserIdentity, I have:
Yii::app()->language = $profile['language'];
I tried to force language to french:
Yii::app()->language = 'fr-fr';
I also tried to move this instruction to LoginForm.login() or SiteController.actionLogin() but without any success.
The value you set for CApplication::language has to match the name of the directory containing your messages or views. So take a look at what those are. The suggested convention in Yii is language-code userscore region-code, all in lowercase, e.g. ‘en_us’ or ‘fr_fr’. I’ve seen the language only without the underscore and region code, but a hyphen, as you used in ‘fr-fr’, is unconventional.