i found this but dont know how to use this


<?php 
$google->FromLang = 'he'; 
$google->ToLang = 'en'; 
echo $google->translate('×©×œ×•×  ×¢×•×œ× !'); 
$google->DebugMsg //Gets all error messages 
$google->DebugStatus //Gets all status codes, 200 = ok, 400 = Invalid languages 

?> 
  
<?php 
class GoogleHelper extends AppHelper { 
    //    This Helper Based on Jamie Telin's ([email protected]) 
GoogleTranslateApi v1.1 

    // 
    //    $google->FromLang = 'he'; 
    //    $google->ToLang = 'en'; 
    //    echo $google->translate('×©×œ×•×  ×¢×•×œ× !'); 
    //    API version might change, so change $Version if needed 
    //    $google->DebugMsg //Gets all error messages 
    //    $google->DebugStatus //Gets all status codes, 200 = ok, 400 = Invalid 
languages 


    var $BaseUrl = 
'http://ajax.googleapis.com/ajax/services/language/translate'; 
    var $FromLang = 'he'; 
    var $ToLang = 'en'; 
    var $Version = '1.0'; 

    var $CallUrl; 

    var $Text = '×©×œ×•×  ×¢×•×œ× !'; 

    var $TranslatedText; 
    var $DebugMsg; 
    var $DebugStatus; 

    function makeCallUrl(){ 
        $this->CallUrl = $this->BaseUrl; 
        $this->CallUrl .= "?v=" . $this->Version; 
        $this->CallUrl .= "&q=" . urlencode($this->Text); 
        $this->CallUrl .= "&langpair=" . $this->FromLang; 
        $this->CallUrl .= "%7C" . $this->ToLang; 
    } 

    function translate($text = ''){ 
        if($text != ''){ 
            $this->Text = $text; 
        } 
        $this->makeCallUrl(); 
        if($this->Text != '' && $this->CallUrl != ''){ 
            $handle = fopen($this->CallUrl, "rb"); 
            $contents = ''; 
            while (!feof($handle)) { 
            $contents .= fread($handle, 8192); 
            } 
            fclose($handle); 

            $json = json_decode($contents, true); 

            if($json['responseStatus'] == 200){ //If request was ok 
                $this->TranslatedText = $json['responseData'][
'translatedText']; 
                $this->DebugMsg = $json['responseDetails']; 
                $this->DebugStatus = $json['responseStatus']; 
                return $this->TranslatedText; 
            } else { //Return some errors 
                return false; 
                $this->DebugMsg = $json['responseDetails']; 
                $this->DebugStatus = $json['responseStatus']; 
            } 
        } else { 
            return false; 
        } 
    } 
}//END OF CLASS 
?> 
 
 

>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to