How To Switch Locales/languages For Different Users In Yii

I have designed a web application, It works for two different users say user1 and user2, and both of the users need the view in different languages.

I have studied about yii:t() but by that method we have to define language in main.config, which set the same language for both users.

How can I translate my view in different languages for both users?

Yii::app()->language is a writeable property.

So you can set the language whereever you want.

For example in the init() method of your BaseController.




  Yii::app()->language = 'de' ... or the users language from the db ...