src/GoogleTranslate.php
public static function translate($source, $target, $text)
    {
        // Request translation
        $response = self::requestTranslation($source, $target, $text);

        // Get translation text
        // $response = self::getStringBetween("onmouseout=\"this.style.backgroundColor='#fff'\">", "</span></div>", strval($response));

        // Clean translation
        $translation = self::getSentencesFromJSON($response);

        return $translation;
    }
public static function translate($source, $target, $text)
    {
        // Request translation
        $response = self::requestTranslation($source, $target, $text);

        // Get translation text
        // $response = self::getStringBetween("onmouseout=\"this.style.backgroundColor='#fff'\">", "</span></div>", strval($response));

        // Clean translation
        $translation = self::getSentencesFromJSON($response);

        return $translation;
    }
public static function translate ( $ source , $ target , $ text ) { // Request translation $ response = self :: requestTranslation ( $ source , $ target , $ text ) ; // Get translation text // $response = self::getStringBetween("onmouseout=\"this.style.backgroundColor='#fff'\">", "</span></div>", strval($response)); // Clean translation $ translation = self :: getSentencesFromJSON ( $ response ) ; return $ translation ; }
Retrieves the translation of a text

@param string $source
Original language of the text on notation xx. For example: es, en, it, fr...
@param string $target
Language to which you want to translate the text in format xx. For example: es, en, it, fr...
@param string $text
Text that you want to translate

@return string a simple string with the translation of the text in the target language
Retrieves the translation of a text