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() {
Yii::$app->language='es';
return $this->render('index');
}
English —>
public function actionEnglish() {
Yii::$app->language='en';
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 ?
Thanks!