public function translation($locale = null)
    {
        if (!$this->has('id') || !$this->has('content_type_slug')) {
            throw new FatalErrorException(__d('content', "Missing properties 'id' or 'content_type_slug', make sure to include them using Query::select()."));
        }

        if ($locale === null) {
            $locale = I18n::locale();
        }

        return TableRegistry::get('Content.Contents')
            ->find()
            ->select(['id', 'slug', 'content_type_slug', 'language'])
            ->where([
                'translation_for' => $this->id,
                'language' => $locale,
                'status' => 1,
            ])
            ->first();
    }
public function translation($locale = null)
    {
        if (!$this->has('id') || !$this->has('content_type_slug')) {
            throw new FatalErrorException(__d('content', "Missing properties 'id' or 'content_type_slug', make sure to include them using Query::select()."));
        }

        if ($locale === null) {
            $locale = I18n::locale();
        }

        return TableRegistry::get('Content.Contents')
            ->find()
            ->select(['id', 'slug', 'content_type_slug', 'language'])
            ->where([
                'translation_for' => $this->id,
                'language' => $locale,
                'status' => 1,
            ])
            ->first();
    }
public function translation ( $ locale = null ) { if ( ! $ this -> has ( 'id' ) || ! $ this -> has ( 'content_type_slug' ) ) { throw new FatalErrorException ( __d ( 'content' , "Missing properties 'id' or 'content_type_slug', make sure to include them using Query::select()." ) ) ; } if ( $ locale === null ) { $ locale = I18n :: locale ( ) ; } return TableRegistry :: get ( 'Content.Contents' ) -> find ( ) -> select ( [ 'id' , 'slug' , 'content_type_slug' , 'language' ] ) -> where ( [ 'translation_for' => $ this -> id , 'language' => $ locale , 'status' => 1 , ] ) -> first ( ) ; }
Find if this content has a translation to the given locale code.

@param string|null $locale Locale code for which look for translations,
if not given current language code will be used
@return mixed Translation entity if exists, null otherwise
@throws Cake\Error\FatalErrorException When if any of the required
properties is not present in this entity
Find if this content has a translation to the given locale code .