Reading list Switch to dark mode

    Usage of Google Translator Api For Free

    Updated 20 November 2013

    function curl($url,$params = array(),$is_coockie_set = false){
    /* STEP 1. let’s create a cookie file */
    $ckfile = tempnam ("/tmp", "CURLCOOKIE");
    /* STEP 2. visit the homepage to set the cookie properly */
    $ch = curl_init ($url);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec ($ch);
    $str = ''; $str_arr= array();
    foreach($params as $key => $value)
    $str_arr[] = urlencode($key)."=".urlencode($value);
    $str = '?'.implode('&',$str_arr);
    /* STEP 3. visit cookiepage.php */
    $Url = $url.$str;
    $ch = curl_init ($Url);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec ($ch);
    return $output;
    function Translate($word,$conversion = 'hi_to_en')
    $word = urlencode($word);
    // dutch to english
    if($conversion == 'nl_to_en')
    $url = ''.$word.'&hl=en&sl=nl&tl=en&multires=1&otf=2&pc=1&ssel=0&tsel=0&sc=1';
    // english to hindi
    if($conversion == 'en_to_hi')
    $url = ''.$word.'&hl=en&sl=en&tl=hi&ie=UTF-8&oe=UTF-8&multires=1&otf=1&ssel=3&tsel=3&sc=1';
    // hindi to english
    if($conversion == 'hi_to_en')
    $url = ''.$word.'&hl=en&sl=hi&tl=en&ie=UTF-8&oe=UTF-8&multires=1&otf=1&pc=1&trs=1&ssel=3&tsel=6&sc=1';
    //$url = ''.$word.'&hl=en&sl=nl&tl=en&multires=1&otf=2&pc=1&ssel=0&tsel=0&sc=1';
    $name_en = curl($url);
    $name_en = explode('"',$name_en);
    return  $name_en[1];
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    echo "<br><br> English To Hindi <br> ";
    echo  Translate('legal notice: This is an abuse of google translator services ,  you must pay for this.','en_to_hi');
    echo "<br><br> Dutch To English <br>";
    echo  Translate('Disclaimer: Dit is een misbruik van Google Translator diensten, moet u betalen.','nl_to_en');

    Start your headless eCommerce
    Find out More
    . . .

    Leave a Comment

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


  • sandy
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home