How Use The Missingtranslationevent

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?

Anywhere before event is triggered.

And where is this for the missingTranslation event? If i put this in the init() of my (base)Controller, nothing happens.

It’s not application event but MessageSource event.

I see, i got it working now, thanks:


Event::on(MessageSource::className(), MessageSource::EVENT_MISSING_TRANSLATION, function($event){


});