public function detect($text)
    {
        $requestUrl = $this->buildRequestUrl($this->getDetectUrl(), [
            'q' => $text
        ]);

        $response = $this->getResponse($requestUrl);

        if (isset($response['data']['detections'])) {
            return $response['data']['detections'][0][0]['language'];
        }
        throw new TranslateException('Could not detect provided text language.');
    }
public function detect($text)
    {
        $requestUrl = $this->buildRequestUrl($this->getDetectUrl(), [
            'q' => $text
        ]);

        $response = $this->getResponse($requestUrl);

        if (isset($response['data']['detections'])) {
            return $response['data']['detections'][0][0]['language'];
        }
        throw new TranslateException('Could not detect provided text language.');
    }
public function detect ( $ text ) { $ requestUrl = $ this -> buildRequestUrl ( $ this -> getDetectUrl ( ) , [ 'q' => $ text ] ) ; $ response = $ this -> getResponse ( $ requestUrl ) ; if ( isset ( $ response [ 'data' ] [ 'detections' ] ) ) { return $ response [ 'data' ] [ 'detections' ] [ 0 ] [ 0 ] [ 'language' ] ; } throw new TranslateException ( 'Could not detect provided text language.' ) ; }
Detects language of specified text string

@param $text
@return string
@throws TranslateException
Detects language of specified text string