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();
     }
 }
Пример #2
0
 public function __construct(TranslationKeyModel $key, $withPhrases = false)
 {
     $this->id = $key->getId();
     $this->identifier = (string) $key->getIdentifier();
     $this->resourceId = $key->getResource()->getId();
     if ($withPhrases) {
         foreach ($key->getPhrases() as $phrase) {
             $locale = $phrase->getLocale();
             $this->phrases[(string) $locale] = new TranslationPhrase($phrase);
         }
     }
 }
Пример #3
0
 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();
 }