Adds a TranslationUnit instance to the file.
It is appenned at the end of
collection.

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param  TranslationUnit translationUnit
@return mixed
344936
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);
    }
751802
public TranslationMap doImport() {
        try {
            for (String locale : LOCALES) {
                TranslationHashMap trMap = new TranslationHashMap(getLocale(locale));
                trMap.doImport(TranslationMap.class.getResourceAsStream(locale + ".txt"));
                add(trMap);
            }
            postImportHook();
            return this;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
751751
public function addTranslation(BusCardContentTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
631743
public function hasSameTranslationUnitTarget( tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $returnValue = (bool) false;

        
        $returnValue = $this->getTarget() == $translationUnit->getTarget();
        

        return (bool) $returnValue;
    }
676534
private function importSingleTranslation($keyword, $text, $locale, $filename, $domain, $force = false)
    {
        if (strlen($keyword) > 255) {
            return false;
        }

        $translationGroup = $this->translationGroupManager->getTranslationGroupByKeywordAndDomain($keyword, $domain);

        if (!$translationGroup->hasTranslation($locale)) {
            $this->translationGroupManager->addTranslation($translationGroup, $locale, $text, $filename);

            return true;
        }

        if (true === $force) {
            $this->translationGroupManager->updateTranslation($translationGroup, $locale, $text, $filename);

            return true;
        }

        return false;
    }
1049448
public function addTranslation(\Haven\CoreBundle\Entity\ExternalLinkTranslation $translations)
    {
        $translations->setParent($this);
        $this->translations[] = $translations;
    
        return $this;
    }
1068165
public function addTranslation($localPath, $crowdinPath, $exportPattern = null, $title = null)
    {
        $translation = new Translation($localPath, $crowdinPath);
        $translation->setExportPattern($exportPattern);
        $translation->setTitle($title);

        $this->translations[] = $translation;

        return $this;
    }
1318309
public function add(TranslatorInterface $translator)
    {
        $hash = spl_object_hash($translator);

        $this->translators[$hash] = $translator;

        return $this;
    }
566775
public function removeTranslationUnit(tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $tus = $this->getTranslationUnits();
        for ($i = 0; $i < count($tus); $i ++) {
            if ($tus[$i] === $translationUnit) {
                unset($tus[$i]);
                break;
            }
        }
        
        throw new tao_helpers_translation_TranslationException('Cannot remove Translation Unit. Not Found.');
    }
632880
public function addTranslation(Translation $translation)
    {
        $key = "{$translation->language()}::{$translation->domain()}";
        $name = "{$translation->domain()}{$this->types[$translation->type()]}";
        $this->translationService()
            ->addTranslationFilePattern(
                $translation->type(),
                $translation->path(),
                "%s/{$name}",
                $translation->domain()
            );
        $this->translations[$key] = $translation;
        return $this;
    }
637073
public function addTranslation(\Sulu\Bundle\ProductBundle\Entity\AttributeSetTranslation $translations)
    {
        $this->translations[] = $translations;

        return $this;
    }
129570
public function hasSameTranslationUnitSubject( tao_helpers_translation_RDFTranslationUnit $translationUnit)
    {
        $returnValue = (bool) false;

        
        $returnValue = $this->getSubject() == $translationUnit->getSubject();
        

        return (bool) $returnValue;
    }
476649
public function set_translation(\Skeleton\I18n\Translation $translation) {
		if ($this->i18n_available === true) {
			$this->translation = $translation;
		} else {
			throw new \Exception('Translation is not available, class not found');
		}
	}
256760
public function addContentTypeTranslation(
        TranslationAddData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: 'add-translation';

        return $this->formFactory->createNamed($name, TranslationAddType::class, $data);
    }
1095232
protected function formatOne($transUnit)
    {
        if (is_object($transUnit)) {
            $transUnit = $this->toArray($transUnit);
        } elseif (StorageInterface::STORAGE_MONGODB == $this->storage) {
            $transUnit['id'] = $transUnit['_id']->{'$id'};
        }

        $formatted = array(
            '_id'     => $transUnit['id'],
            '_domain' => $transUnit['domain'],
            '_key'    => $transUnit['key'],
        );

        // add locales in the same order as in managed_locales param
        foreach ($this->localeManager->getLocales() as $locale) {
            $formatted[$locale] = '';
        }

        // then fill locales value
        foreach ($transUnit['translations'] as $translation) {
            if (in_array($translation['locale'], $this->localeManager->getLocales())) {
                $formatted[$translation['locale']] = $translation['content'];
            }
        }

        return $formatted;
    }
49608
public function addTranslation(LayoutTranslation $translation)
    {
        $this->translations->add($translation);
        $translation->setLayout($this);
    }
1037727
public void addFolderTranslation(String translation) {

        m_folderTranslations.add(translation);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_ADD_FOLDER_TRANSLATION_1, translation));
        }
    }