Subject: Google Translation

Posted on: 22/06/05 10:53pm
By: phpsocialclub

I have written a simple function to create a "translate this page" block for Google.

If you add this to your lb_custom.php, you will be able to get a block that will link a page to the google translation service.

You will not be able to login however because the page is actually from google and the cookies will not transfer. If anyone can think of a work around for that, I would love to hear about it.

function phpblock_translate()

{
global $_SERVER ; 

$return = "Translate this page with <a href='http://www.google.com/language_tools'>Google</a><p>" ; 

$googleURL = "http://translate.google.com/translate?u=" ;

$url = "http://" . $_SERVER["HTTP_HOST"] .  $_SERVER["REQUEST_URI"] ;
$url = urlencode($url) ; 

$trans['de'] = "Deutsch" ;
$trans['fr'] = "Français" ;
$trans['es'] = "Español" ;
$trans['it'] = "Italiano" ;
$trans['pt'] = "Portuguese" ;
$trans['ja'] = "Japanese" ;
$trans['ko'] = "Korean" ;
$trans['zh-CN'] = "Chinese" ;

foreach ($trans as $key => $value)
    {
    
    $transURL = $googleURL . $url . "&langpair=en%7C" . $key . "&hl=en" ; ;  
    
    $return .= "<a href ='$transURL'>$value</a>" ;
    
   
    
    }

$return .= "You will be logged out if you use Google Translation" ; 

return $return ;

}





Edit: I am an idiot, if someone could move this to the Blocks topic that would be helpful, thanks

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=54653