/**
  * Short description of method hasSameTranslationUnitTarget
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  TranslationUnit translationUnit
  * @return boolean
  */
 public function hasSameTranslationUnitTarget(tao_helpers_translation_TranslationUnit $translationUnit)
 {
     $returnValue = (bool) false;
     $returnValue = $this->getTarget() == $translationUnit->getTarget();
     return (bool) $returnValue;
 }
 /**
  * Adds a TranslationUnit instance to the file. It is appenned at the end of
  * collection.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  TranslationUnit translationUnit
  * @return mixed
  */
 public function addTranslationUnit(tao_helpers_translation_TranslationUnit $translationUnit)
 {
     // If the translation unit exists, we replace the target with the new one if it exists.
     foreach ($this->getTranslationUnits() as $tu) {
         if ($tu->getSource() == $translationUnit->getSource()) {
             // If we are here, it means that this TU is being overriden by
             // another one having the same source...
             //
             // Let's make sure we don't override the existing one with an empty target!
             if ($translationUnit->getTarget() !== '') {
                 $tu->setTarget($translationUnit->getTarget());
                 $tu->setAnnotations($translationUnit->getAnnotations());
             }
             return;
         }
     }
     // If we are here, it means that this TU does not exist.
     $translationUnit->setSourceLanguage($this->getSourceLanguage());
     $translationUnit->setTargetLanguage($this->getTargetLanguage());
     array_push($this->translationUnits, $translationUnit);
 }
Beispiel #3
0
 /**
  * Adds a TranslationUnit instance to the file. It is appenned at the end of
  * collection.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param tao_helpers_translation_TranslationUnit $translationUnit
  * @return mixed
  */
 public function addTranslationUnit(tao_helpers_translation_TranslationUnit $translationUnit)
 {
     // If the translation unit exists, we replace the target with the new one if it exists.
     // also now we take care about context
     /** @var tao_helpers_translation_TranslationUnit $tu */
     foreach ($this->getTranslationUnits() as $tu) {
         if ($tu->getSource() == $translationUnit->getSource() && (!$translationUnit->getContext() || $tu->getContext() == $translationUnit->getContext())) {
             $tu->setTarget($translationUnit->getTarget());
             $tu->setAnnotations($translationUnit->getAnnotations());
             return;
         }
     }
     // If we are here, it means that this TU does not exist.
     $translationUnit->setSourceLanguage($this->getSourceLanguage());
     $translationUnit->setTargetLanguage($this->getTargetLanguage());
     $tus = $this->getTranslationUnits();
     array_push($tus, $translationUnit);
     $this->setTranslationUnits($tus);
 }