Check if the instance passed as parameter $translation is a valid child translation for this object
@param INabuTranslation $translation Translation instance to check
@return bool Return true if a valid object is passed as instance or false elsewhere
321834
protected function checkForValidTranslationInstance($translation)
    {
        return ($translation !== null &&
                $translation instanceof CNabuSiteRoleLanguage &&
                $translation->matchValue($this, 'nb_site_id') &&
                $translation->matchValue($this, 'nb_role_id')
        );
    }
728473
private function checkXSS(GettextTranslation $translation)
    {
        $sourceText = $translation->getOriginal();
        $translatedText = $translation->getTranslation();
        if ($translation->hasPlural()) {
            $sourceText .= "\n" . $translation->getPlural();
            $translatedText .= "\n" . implode("\n", $translation->getPluralTranslation());
        }
        $checkTags = false;
        foreach (['<', '=', '"'] as $char) {
            if (strpos($sourceText, $char) === false) {
                if (strpos($translatedText, $char) !== false) {
                    throw new UserMessageException(t('The translation for the string \'%1$s\' can\'t contain the character \'%2$s\'.', $translation->getOriginal(), $char));
                }
            } else {
                if ($char === '<') {
                    $checkTags = true;
                }
            }
        }
        if ($checkTags) {
            $m = null;
            $sourceTags = preg_match_all('/<\\w+/', $sourceText, $m) ? array_unique($m[0]) : [];
            $translatedTags = preg_match_all('/<\\w+/', $translatedText, $m) ? array_unique($m[0]) : [];
            $extraTags = array_diff($translatedTags, $sourceTags);
            switch (count($extraTags)) {
                case 0:
                    break;
                case 1:
                    throw new UserMessageException(t('The translation for the string \'%1$s\' can\'t contain the string \'%2$s\'.', $translation->getOriginal(), current($extraTags)));
                default:
                    $error = t('The translation for the string \'%1$s\' can\'t contain these strings:', $translation->getOriginal());
                    $error .= "\n- " . implode("\n- ", $extraTags);
                    throw new UserMessageException($error);
            }
        }
    }
662175
public function isUnique(TranslationModel $translationModel)
    {
        $qb = $this->createQueryBuilder('t');
        $count = $qb->select('COUNT(t.id)')
            ->where('t.domain = :domain')
            ->andWhere('t.keyword = :keyword')
            ->setParameter('domain', $translationModel->getDomain())
            ->setParameter('keyword', $translationModel->getKeyword())
            ->getQuery()
            ->getSingleScalarResult();

        return $count == 0;
    }
566556
public function addTranslation(\Haven\CmsBundle\Entity\TemplatePageTranslation $translation)
    {
        $translation->setParent($this);
        $this->translations[] = $translation;

        return $this;
    }
861275
public function addTranslation(Translation $translation, $isUpdate = true)
    {
        $this->translations[$translation->getLocale()] = $translation;
        if ($isUpdate) {
            $this->setIsModified(true);
        }
    }
860890
public function entityHasTranslation(string $entityName): bool
    {
        $hasKey = in_array($entityName, $this->translationModelKeys());

        if ($hasKey) {
            return ! empty($hasKey);
        }

        return false;
    }
1207313
public function addTranslation(TranslationInterface $translation)
    {
        if (!$this->translations->containsKey($translation->getLocale())) {
            $this->translations->set($translation->getLocale(), $translation);
            $translation->setTranslatable($this);
        }

        return $this;
    }
1325024
public static function setDefaultTranslator($translator = null)
    {
        if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) {
            self::$_defaultTranslator = $translator;
        } elseif ($translator instanceof Zend_Translate) {
            self::$_defaultTranslator = $translator->getAdapter();
        } else {
            require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception('Invalid translator specified');
        }
    }
1361282
protected function getSlug(ContentTranslation $translation)
    {
        $path = str_slug($translation->title);

        if ($this->parent_id) {
            $path = $this->parent->getPath($translation->language_code) . '/' . $path;
        }

        return $path;
    }
1279576
protected function validateDataTranslationStore()
    {
        $options = $this->options;
        $this->options += array('parents' => 'data');
        $result = $this->validateTranslation();
        $this->options = $options;

        return $result;
    }
1057790
public function check(TranslatorInterface $translator, $kernelRoot, $fix = false)
    {
        $issues = array();
        /** @var Message[] $messages */
        $messages = $this->getRepository()->findAll();
        foreach ($messages as $message) {
            foreach ($message->getTranslations() as $translation) {
                $translator->setLocale($translation->locale);
                $translated = $translator->trans($message->message, array(), $message->domain);

                $translationFile = 'Resources/translations/' . $message->domain . '.' . $translation->locale . '.db';
                if (!is_file($kernelRoot . '/' . $translationFile)) {
                    if ($fix === true) {
                        touch($kernelRoot . '/' . $translationFile);
                        $msg = 'Translation file app/' . $translationFile . ' created';
                    } else {
                        $msg = 'Translation file app/' . $translationFile . ' is missing. This probably causes some messages not to load';
                    }
                    if (!in_array($msg, $issues)) {
                        $issues[]= $msg;
                    }
                }
                if ($translated != $translation->translation) {
                    $issues[]= sprintf(
                        "Message '%s' from domain '%s' in locale '%s' translates as '%s', but '%s' expected",
                        $message->message,
                        $message->domain,
                        $translation->locale,
                        $translated,
                        $translation->translation
                    );
                }
            }
        }

        return $issues;
    }
1148649
public function hasSameTranslationUnitSourceLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $returnValue = (bool) false;

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

        return (bool) $returnValue;
    }
776974
public function matches($pattern, $translation = null)
	{
		return $this->pattern === $pattern and (!$translation or $translation === $this->translation);
	}
287756
public function hasSameTarget(tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $returnValue = (bool) false;
        
        foreach ($this->getTranslationUnits() as $tu) {
            if ($tu->hasSameTranslationUnitTarget($translationUnit)) {
                $returnValue = true;
                break;
            }
        }
        
        return (bool) $returnValue;
    }
251982
public function hasSameTranslationUnitTargetLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $returnValue = (bool) false;

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

        return (bool) $returnValue;
    }
356129
public function mergeWith(Translation $translation, $options = Merge::DEFAULTS)
    {
        Merge::mergeTranslation($translation, $this, $options);
        Merge::mergeReferences($translation, $this, $options);
        Merge::mergeComments($translation, $this, $options);
        Merge::mergeExtractedComments($translation, $this, $options);
        Merge::mergeFlags($translation, $this, $options);

        return $this;
    }
849718
protected function isTranslationDirty(Model $translation)
    {
        $dirtyAttributes = $translation->getDirty();
        unset($dirtyAttributes[$this->getLocaleKey()]);

        return count($dirtyAttributes) > 0;
    }