Internationalization Problem

Hello Yii Developers!

Im currently developing a Web Site for a proyect @ my University , im using Yii 2 Framework for the Server Side. Right now i am implementing the internationalization part, i’ve managed to have 2 labels on the Yii Navbar and both of them work for changing from Spanish - English and viceversa.

The problem is that , let us suposse, that i’ve changed the language from Spanish to English, the labels and other items of the webpage update fine to the new language, but if i click on the navbar logo, or in another label , it switches back to Spanish, and i want it to keep it in English.

Each language label has an action on the SiteController:

Spanish —>

public function actionSpanish() {


    return $this->render('index');


English —>

public function actionEnglish() {


    return $this->render('index');


on the web.php file i’ve written —>

‘language’ => ‘es’,

‘components’ => [

    'i18n' => [

        'translations' => [

            'app*' => [

                'class' => 'yii\i18n\PhpMessageSource',

                'basePath' => '@app/messages',

                'sourceLanguage' => 'es',




Any thougths on what is happening ?


Every request Yii is reading the config so you need to store the language in a session variable not in the app config.

Hey Jackmoe thanks for the fast reply. How can i do what you say ? Saving the language when the user logs in?