@name            setTranslation ()

@author          Can Berkol

@since           1.0.0
@version         1.0.0

@use             $this->setModified()

@param           mixed $translation

@return          object                $this
166545
public function setTranslation($translation) {
		if(!$this->setModified('translation', $translation)->isModified()) {
			return $this;
		}
		$this->translation = $translation;
		return $this;
	}
150391
public function setTranslatableLang($lang)
    {
        if (is_string($lang)) {
            $lang = new Lang($lang);
        }

        $this->translatableLang = $lang;

        return $this;
    }
846697
public function setTranslation(CategoryTranslationInterface $translation)
    {
        $translationEntity = $this->getTranslationByLocale($translation->getLocale());

        if (!$translationEntity) {
            $translationEntity = $translation;
            $this->entity->addTranslation($translationEntity);
        }

        $translationEntity->setCategory($this->entity);
        $translationEntity->setTranslation($translation->getTranslation());
        $translationEntity->setLocale($translation->getLocale());

        if (null === $this->getId() && null === $this->getDefaultLocale()) {
            // new entity and new translation
            // save first locale as default
            $this->entity->setDefaultLocale($translationEntity->getLocale());
        }
    }
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;
    }
1184227
public function removeTranslation(\Lexik\Bundle\TranslationBundle\Model\Translation $translation)
    {
        $this->translations->removeElement($translation);
    }
201146
public function setTranslator($translator = null)
    {
        if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) {
            $this->_translator = $translator;
        } elseif ($translator instanceof Zend_Translate) {
            $this->_translator = $translator->getAdapter();
        } else {
            include_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception('Invalid translator specified');
        }
        return $this;
    }
901688
public function setTranslations(string $key, array $translations)
    {
        $this->guardAgainstUntranslatableAttribute($key);

        foreach ($translations as $locale => $translation) {
            $this->setTranslation($key, $locale, $translation);
        }

        return $this;
    }
1311707
protected static function setTranslationsForMessageFromService($selfEdit, $msgInstanceName, $language, $translations) {
		$translationService = new InstanceProxy($msgInstanceName, $selfEdit);
		return $translationService->setMessages($translations, $language);
	}
1207313
public function addTranslation(TranslationInterface $translation)
    {
        if (!$this->translations->containsKey($translation->getLocale())) {
            $this->translations->set($translation->getLocale(), $translation);
            $translation->setTranslatable($this);
        }

        return $this;
    }
451155
public function addTranslation(\Haven\CmsBundle\Entity\TextContentTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
979100
public function setTranslations(Locale $locale, Translations $translations)
    {
        $this->translations[$locale->getID()] = [$locale, $translations];
    }
1029458
public function setTranslator(\Symfony\Component\Translation\Translator $translator)
    {
        $this->translator = $translator;
        return $this->translator;
    }
1367512
public function setTranslations($key, array $translations)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

        foreach ($translations as $locale => $translation) {
            $this->setTranslation($key, $locale, $translation);
        }

        return $this;
    }
633366
protected function setTranslations() {
        if( $this->getAttribute('cache_time') ) {
            $translations = Cache::remember('users', $this->getAttribute('cache_time'), function() {
                $translations = $this->getRepository()
                    ->allTranslations()
                    ->toArray();

                return $this->prepareTranslations(
                    $translations
                );
            });
        } else {
            $translations = $this->getRepository()
                ->allTranslations()
                ->toArray();

            $translations = $this->prepareTranslations(
                $translations
            );
        }

        $this->translations = $translations;

        return $this;
    }
721332
public function transform($translation)
    {
        $translation = $this->entityToArray(BlockTranslation::class, $translation);
        return [
            'id'           => (int) $translation['id'],
            'langCode'     => $translation['lang_code'],
            'title'        => $translation['title'],
            'body'         => $translation['body'],
            'customFields' => $this->transformCustomFields($translation),
            'isActive'     => (bool) $translation['is_active'],
            'createdAt'    => $translation['created_at'],
            'updatedAt'    => $translation['updated_at'],
        ];
    }
978870
public function transform($translation)
    {
        $translation = $this->entityToArray(FileTranslation::class, $translation);
        return [
            'id'          => (int) $translation['id'],
            'langCode'    => $translation['lang_code'],
            'title'       => $translation['title'],
            'description' => $translation['description'],
            'createdAt'   => $translation['created_at'],
            'updatedAt'   => $translation['updated_at'],
        ];
    }
859133
private function translate(): self
    {
        if (empty($this->translations)) {
            return $this;
        }

        $lang = $this->get('lang');

        foreach ($this->attributes as $key => $attribute) {
            if (in_array($key, $this->translations, true)) {
                $this->set($key, __($attribute, [], $lang));
            }
        }

        return $this;
    }