/** * @param MissingTranslationEvent $event */ public static function missingTranslation(MissingTranslationEvent $event) { $driver = Yii::$app->getDb()->getDriverName(); $caseInsensitivePrefix = $driver === 'mysql' ? 'binary' : ''; $sourceMessage = SourceMessage::find()->where('category = :category and message = ' . $caseInsensitivePrefix . ' :message', [':category' => $event->category, ':message' => $event->message])->with('messages')->one(); if (!$sourceMessage) { $sourceMessage = new SourceMessage(); $sourceMessage->setAttributes(['category' => $event->category, 'message' => $event->message], false); $sourceMessage->save(false); } $sourceMessage->initMessages(); $sourceMessage->saveMessages(); }
/** * @return array|SourceMessage[] */ public static function getCategories() { return SourceMessage::find()->select('category')->distinct('category')->asArray()->all(); }