src/Repositories/TranslationRepository.php
public function translateText($text, $textLocale, $targetLocale)
    {
        $table = $this->model->getTable();

        return $this->model
            ->newQuery()
            ->select($table . '.text')
            ->from($table)
            ->leftJoin("{$table} as e", function ($join) use ($table, $text, $textLocale) {
                $join->on('e.namespace', '=', "{$table}.namespace")
                    ->on('e.group', '=', "{$table}.group")
                    ->on('e.item', '=', "{$table}.item");
            })
            ->where("{$table}.locale", $targetLocale)
            ->where('e.locale', $textLocale)
            ->where('e.text', $text)
            ->get()
            ->pluck('text')
            ->unique()
            ->toArray();
    }
public function translateText($text, $textLocale, $targetLocale)
    {
        $table = $this->model->getTable();

        return $this->model
            ->newQuery()
            ->select($table . '.text')
            ->from($table)
            ->leftJoin("{$table} as e", function ($join) use ($table, $text, $textLocale) {
                $join->on('e.namespace', '=', "{$table}.namespace")
                    ->on('e.group', '=', "{$table}.group")
                    ->on('e.item', '=', "{$table}.item");
            })
            ->where("{$table}.locale", $targetLocale)
            ->where('e.locale', $textLocale)
            ->where('e.text', $text)
            ->get()
            ->pluck('text')
            ->unique()
            ->toArray();
    }
public function translateText ( $ text , $ textLocale , $ targetLocale ) { $ table = $ this -> model -> getTable ( ) ; return $ this -> model -> newQuery ( ) -> select ( $ table . '.text' ) -> from ( $ table ) -> leftJoin ( "{$table} as e" , function ( $ join ) use ( $ table , $ text , $ textLocale ) { $ join -> on ( 'e.namespace' , '=' , "{$table}.namespace" ) -> on ( 'e.group' , '=' , "{$table}.group" ) -> on ( 'e.item' , '=' , "{$table}.item" ) ; } ) -> where ( "{$table}.locale" , $ targetLocale ) -> where ( 'e.locale' , $ textLocale ) -> where ( 'e.text' , $ text ) -> get ( ) -> pluck ( 'text' ) -> unique ( ) -> toArray ( ) ; }
Check if there are existing translations for the given text in the given locale for the target locale.

@param  string  $text
@param  string  $textLocale
@param  string  $targetLocale
@return array
Check if there are existing translations for the given text in the given locale for the target locale .