How can I set language from url. I dont want set language in each controller. I create CommonController and other controllers extends from it. In this controller set language
I use a behaviour, which I have named ConfigBehavior.
I use this behavior to set and update various app parameters, such as language.
For language I set a default language, then listen for the $_GET request to change it.
namespace common\behaviors;
use Yii;
use yii\base\BootstrapInterface;
use yii\base\Application;
use frontend\models\Language;
class ConfigBehavior implements BootstrapInterface
{
public function bootstrap($app)
{
$app->on(Application::EVENT_BEFORE_REQUEST, function () {
// do stuff
});
}
}