I have project and I want to load website with default language and sourceLanguage or etc., but I cant change language in controller and in view.

\Yii::$app->language = function_any_logic_for_website();
//not working for controller and view, and not set language

How to resolve problem?