예제 #1
0
파일: Module.php 프로젝트: athl64/yii2-i18n
 /**
  * @param MissingTranslationEvent $event
  */
 public static function missingTranslation(MissingTranslationEvent $event)
 {
     $sourceMessage = static::getSourceMessage($event);
     if (!$sourceMessage) {
         $sourceMessage = new SourceMessage();
         $sourceMessage->setAttributes(['category' => $event->category, 'message' => $event->message], false);
         $sourceMessage->save(false);
     }
     $sourceMessage->initMessages();
     $sourceMessage->saveMessages();
 }
예제 #2
0
 /**
  * @param string $category
  * @param string $message
  * @return SourceMessage
  */
 private function getSourceMessage($category, $message)
 {
     $params = ['category' => $category, 'message' => $message];
     $sourceMessage = SourceMessage::find()->where($params)->with('messages')->one();
     if (!$sourceMessage) {
         $sourceMessage = new SourceMessage();
         $sourceMessage->setAttributes($params, false);
         $sourceMessage->save(false);
     }
     return $sourceMessage;
 }