/** * @param SourceMessage $sourceMessage * @param string $language * @param string $translation */ private function setTranslation($sourceMessage, $language, $translation) { /** @var Message[] $messages */ $messages = $sourceMessage->messages; if (isset($messages[$language]) && $messages[$language]->translation === null) { $messages[$language]->translation = $translation; $messages[$language]->save(false); } elseif (!isset($messages[$language])) { $message = new Message(); $message->setAttributes(['language' => $language, 'translation' => $translation], false); $sourceMessage->link('messages', $message); } }