Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 09:23 am EDT

Geeklog Forums

Google Translation


Status: offline

phpsocialclub

Forum User
Junior
Registered: 03/05/03
Posts: 30
Location:North Carolina
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.

Text Formatted Code

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
I work for a Wilmington NC Attorney
 Quote

All times are EDT. The time is now 09:23 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content