Difference between #75 and #76 of
Yii v2 snippet guide

Revision #76 has been created by rackycz on Sep 20, 2019, 3:08:28 PM with the memo:

edit
« previous (#75) next (#77) »

Changes

Title unchanged

Yii v2 for beginners

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
*Note that this approach will always redirect user to the new action and his work will be lost. Nevertheless this approach is very simple so I am using it in small projects. More complex projects may require an ajax call when language is changed and then updating texts using javascript so reload is not needed and user's work is preserved. But I expect that when someone opens the web, he/she sets the language immediately and then there is no need for further changes.*

The setLang action looks like this:

```php
    public function actionSetLang($langID = "") {        $allowedLanguages = Yii::$app->params["allowedLanguages"];        if ($langID && trim($langID) !== "" && in_array($langID, $allowedLanguages)) {          Yii::$app->session->set('langID', $langID);        }        return $this->redirect(['site/index']);     } ``` Access rights --- ... text ...
7 0
4 followers
Viewed: 274 993 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: a year ago
Update Article

Revisions

View all history