예제 #1
0
 /**
  * @param TranslationMapInterface $map
  * @return string
  */
 private function extractFromFallbacks(TranslationMapInterface $map)
 {
     $english = Language::get('en');
     if ($map->has($english)) {
         return $map->get($english);
     }
     $translations = $map->getAll();
     reset($translations);
     /** @var TranslationInterface $translation */
     $translation = current($translations);
     return $map->get($translation->getLanguage());
 }
예제 #2
0
 /**
  * @param TranslationMapInterface $other
  * @return boolean
  */
 public function equals(TranslationMapInterface $other)
 {
     if ($this === $other) {
         return true;
     }
     $otherData = $other->getAll();
     if (count($this->translations) !== count($otherData)) {
         return false;
     }
     foreach ($this->translations as $translation) {
         if (!$other->has($translation->getLanguage())) {
             return false;
         }
         if ($other->get($translation->getLanguage()) !== $translation->getText()) {
             return false;
         }
     }
     return true;
 }