public function __construct(Key $key, Locale $source, Locale $target) { $sourcePhrase = $key->getPhrase($source) ?: new Phrase($key, $source); $targetPhrase = $key->getPhrase($target) ?: new Phrase($key, $target); $this->id = $key->getId(); $this->resourceId = $key->getResource()->getId(); $this->key = (string) $key->getIdentifier(); $this->sourcePhrase = (string) $sourcePhrase->getText(); $this->sourceLocale = (string) $sourcePhrase->getLocale(); $this->targetPhrase = (string) $targetPhrase->getText(); $this->targetLocale = (string) $targetPhrase->getLocale(); $this->isTranslated = null !== $key->getPhrase($target); $this->isApproved = $targetPhrase->isApproved(); }
public function __construct(Key $key, Locale $locale) { $this->key = $key; $this->locale = $locale; if (null !== ($phrase = $key->getPhrase($locale))) { $this->text = $phrase->getText(); $this->isApproved = $phrase->isApproved(); } }