so I have to wait for UrlManager to set $_GET[‘language’] parameter for me to know what is this request’s language.
My question is, when and where is the best time and place for me to use $_GET[‘language’] parameter and set Yii::$app->language based on it. It would be great if could be done in bootstrapping but that’s too soon and UrlManager has no yet set $_GET[‘language’] in that phase. I’m currently using onBeforeAction event in my application config:
'on beforeAction' => function ($event) {
kalpok\i18n\LanguageSetter::setup();
},
any idea? better place for it? or that’s just fine there?
My app has several modules and controllers, I prefer a single place for it. also having all controllers extend a parent just for this reason does not feel right to me.
I preloaded UrlManager as you said, but it seems preloading it does not make it run parseRequest() method which is what’s needed here.