Model/Translation/TranslatableTrait.php
public function getTranslation($lang, $create = false)
    {
        foreach ($this->translations as $translation) {
            if ($lang == $translation->getLang()) {
                return $translation;
            }
        }

        if ($create) {
            $class = $this->getTranslationClass();

            /** @var TranslationInterface $translation */
            $translation = new $class();
            $translation->setLang($lang);
            $this->addTranslation($translation);

            return $translation;
        }

        return null;
    }
public function getTranslation($lang, $create = false)
    {
        foreach ($this->translations as $translation) {
            if ($lang == $translation->getLang()) {
                return $translation;
            }
        }

        if ($create) {
            $class = $this->getTranslationClass();

            /** @var TranslationInterface $translation */
            $translation = new $class();
            $translation->setLang($lang);
            $this->addTranslation($translation);

            return $translation;
        }

        return null;
    }
public function getTranslation ( $ lang , $ create = false ) { foreach ( $ this -> translations as $ translation ) { if ( $ lang == $ translation -> getLang ( ) ) { return $ translation ; } } if ( $ create ) { $ class = $ this -> getTranslationClass ( ) ; /** @var TranslationInterface $translation */ $ translation = new $ class ( ) ; $ translation -> setLang ( $ lang ) ; $ this -> addTranslation ( $ translation ) ; return $ translation ; } return null ; }
Returns the translation in a given language

@param   string  $lang       The language code (eg. 'en')
@param   bool    $create     Whether or not to create if it doesn't exists

@return  TranslationInterface|null
Returns the translation in a given language