January 8, 2024 5:02 am

How to translate with google translate

I have received many requests from my readers on translation of web application so today i have decided to write a tutorial on translate. I have used google translate to translate any word in almost 64 languages simply download package and start translating.

Google-Translate

[wpdm_file id=22]DEMO

Here is some code snippets:

<?php 
    require_once("class.translate.php"); 

    $var = new translate($_POST['from'],$_POST['to']); 
    $content    = "Translation of: '".$_POST['word']."' <b>".$var->get($_POST['word'])."</b>";
?>

Translation Class function which perform translation:

if(!$word){ 

            die("you need to adda a translate word"); 
        } 
        ///we need to encode the word that we want to translate 

        $word = urlencode($word); 

        $url = "http://translate.google.com/?sl=". $this->translate_from ."&tl=". $this->translate_into ."&js=n&prev=_t&hl=it&ie=UTF-8&eotf=1&text=". $word .""; 

        return $url;

Use this simple code and make your applications super cool 🙂

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:

5 responses to “How to translate with google translate”

  1. Mohammad says:

    Dear sir
    Thank you for your tutorial.
    I used your translator but it did not work. it returns only the same word not the meaning. your demo is the same too. please help me to solve the problem.
    Best regards

  2. Priyal Skywide says:

    it did not work

  3. Shaan Ansari says:

    brother it does’nt work i think google translation api is no more free

  4. Not work – Translation of: ‘Hello World’ from English to Thai = Hello World.

  5. Not work – Translation of: ‘Hello World’ from English to Thai = Hello World.

Leave a Reply

Your email address will not be published. Required fields are marked *