Davey
(Davey975)
1
I duck into the I18N code a bit and i saw the MissingTranslationEvent is triggered when a translation could not be found. How can I use this event?
I want to use this event to insert a translation in my database (i’m going to use DbMessageSource) when it’s not inserted yet (in dev mode only).
I probably need to call this somewhere:
Yii::$app->on('missingTranslation', function(){
});
But where?
samdark
(Alexander Makarov)
2
Anywhere before event is triggered.
Davey
(Davey975)
3
And where is this for the missingTranslation event? If i put this in the init() of my (base)Controller, nothing happens.
samdark
(Alexander Makarov)
4
It’s not application event but MessageSource event.
Davey
(Davey975)
5
I see, i got it working now, thanks:
Event::on(MessageSource::className(), MessageSource::EVENT_MISSING_TRANSLATION, function($event){
});