the-botman Posted September 7, 2012 Share Posted September 7, 2012 heya guys... ok this script only works if i translate one word but if i put anything more it gives me an error message please help <?php include 'Include/Header-translate.php'; ?> <html> <head> <title>BhaWAP</title> </head> <body> <div class="hd2"><font color=#FFAD02><strong><center>BhaWAP Online Translation</center></strong></font></div><br> <? $q=$_GET['q']; $from=$_GET['from']; $to=$_GET['to']; $siteurl="http://translate.google.co.in/m?hl=en&sl=$from&tl=$to&ie=UTF-8&prev=_m&q=$q"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ''.$siteurl.''); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-us,en;q=0.7,de-de;q=0.3','Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')); $file = curl_exec($ch); $file=str_replace('>',' => ',$file); $file=str_replace('<br><div dir="ltr" class="t0">','<div class="contentl">Translation:<br/><b>',$file); $file=str_replace('<div class="small blue ub s2">','<div class="contentl">Translate: <b>'.$q.'</b><br/>',$file); //$file=str_replace('</div>','</b>',$file); $file=preg_replace('/<img (.*?)"\/>/is','',$file); $file=preg_replace('/<head>(.*?)<\/head>/is','',$file); $file=preg_replace('/<div class="small center">(.*?)<\/div>/is','',$file); $file=preg_replace('/<span class="small">(.*?)<\/span><\/div>/is','',$file); $file=preg_replace('/<form (.*?)<\/form>/is','',$file); $file=preg_replace('/<a href="(.*?)\>/is','',$file); $file=preg_replace('/<a id="arrow" href="(.*?)\>/is','',$file); $file=str_replace('<div class="small blue ub s2">','<div class="contentl">',$file); $file=str_replace('</a>','',$file); $file=str_replace('Detect language','Auto Detect',$file); $file=str_replace('<br></body></html>','',$file); $file=str_replace('<a id="arrow">','',$file); $file=str_replace('<br><div dir="ltr" class="t0">','<div class="contentl">',$file); $file=str_replace('<body dir="ltr"><div> ','',$file); $file=str_replace('</div><div dir="ltr" class="o1">','<br/>',$file); $file=preg_replace('/<div (.*?)">/is','<div class="contentl">',$file); $file=str_replace('<br>','',$file); echo $file; ?> </b> <div class="contentl"> <form action="translator.php" method="get"> <div> Type the word to translate<br/> <input type="text" value="" name="q"/> <br/> From language <br/> <select name="from"> <option value="auto">Auto Detect</option> <option value="af">Afrikaans</option> <option value="sq">Albanian</option> <option value="ar">Arabic</option> <option value="hy">Armenian</option> <option value="az">Azerbaijani</option> <option value="eu">Basque</option> <option value="be">Belarusian</option> <option value="bg">Bulgarian</option> <option value="ca">Catalan</option> <option value="zh-CN">Chinese</option> <option value="hr">Croatian</option> <option value="cs">Czech</option> <option value="da">Danish</option> <option value="nl">Dutch</option> <option value="en">English</option> <option value="et">Estonian</option> <option value="tl">Filipino</option> <option value="fi">Finnish</option> <option value="fr">French</option> <option value="gl">Galician</option> <option value="ka">Georgian</option> <option value="de">German</option> <option value="el">Greek</option> <option value="ht">Haitian Creole</option> <option value="iw">Hebrew</option> <option value="hi">Hindi</option> <option value="hu">Hungarian</option> <option value="is">Icelandic</option> <option value="id">Indonesian</option> <option value="ga">Irish</option> <option value="it">Italian</option> <option value="ja">Japanese</option> <option value="ko">Korean</option> <option value="lv">Latvian</option> <option value="lt">Lithuanian</option> <option value="mk">Macedonian</option> <option value="ms">Malay</option> <option value="mt">Maltese</option> <option value="no">Norwegian</option> <option value="fa">Persian</option> <option value="pl">Polish</option> <option value="pt">Portuguese</option> <option value="ro">Romanian</option> <option value="ru">Russian</option> <option value="sr">Serbian</option> <option value="sk">Slovak</option> <option value="sl">Slovenian</option> <option value="es">Spanish</option> <option value="sw">Swahili</option> <option value="sv">Swedish</option> <option value="th">Thai</option> <option value="tr">Turkish</option> <option value="uk">Ukrainian</option> <option value="ur">Urdu</option> <option value="vi">Vietnamese</option> <option value="cy">Welsh</option> <option value="yi">Yiddish</option> </select> <br/> To Language <br/> <select name="to"> <option value="af">Afrikaans</option> <option value="sq">Albanian</option> <option value="ar">Arabic</option> <option value="hy">Armenian</option> <option value="az">Azerbaijani</option> <option value="eu">Basque</option> <option value="be">Belarusian</option> <option value="bg">Bulgarian</option> <option value="ca">Catalan</option> <option value="zh-CN">Chinese</option> <option value="hr">Croatian</option> <option value="cs">Czech</option> <option value="da">Danish</option> <option value="nl">Dutch</option> <option value="en">English</option> <option value="et">Estonian</option> <option value="tl">Filipino</option> <option value="fi">Finnish</option> <option value="fr">French</option> <option value="gl">Galician</option> <option value="ka">Georgian</option> <option value="de">German</option> <option value="el">Greek</option> <option value="ht">Haitian Creole</option> <option value="iw">Hebrew</option> <option value="hi">Hindi</option> <option value="hu">Hungarian</option> <option value="is">Icelandic</option> <option value="id">Indonesian</option> <option value="ga">Irish</option> <option value="it">Italian</option> <option value="ja">Japanese</option> <option value="ko">Korean</option> <option value="lv">Latvian</option> <option value="lt">Lithuanian</option> <option value="mk">Macedonian</option> <option value="ms">Malay</option> <option value="mt">Maltese</option> <option value="no">Norwegian</option> <option value="fa">Persian</option> <option value="pl">Polish</option> <option value="pt">Portuguese</option> <option value="ro">Romanian</option> <option value="ru">Russian</option> <option value="sr">Serbian</option> <option value="sk">Slovak</option> <option value="sl">Slovenian</option> <option value="es">Spanish</option> <option value="sw">Swahili</option> <option value="sv">Swedish</option> <option value="th">Thai</option> <option value="tr">Turkish</option> <option value="uk">Ukrainian</option> <option value="ur">Urdu</option> <option value="vi">Vietnamese</option> <option value="cy">Welsh</option> <option value="yi">Yiddish</option> </select> <br/> <input type="submit" value="translate"/> </div> </form> </div> <? echo '<hr><center>'.$GLOBALS["Advert03"].'</center>'."\n"; echo ' <img src="Images/Logos/Logo_Back.gif">'."\n"; echo ' <font face="Verdana" size="2"><b><a href="index.php">Back</b></font></a><br>'."\n"; echo '<hr>'."\n"; include('users-online.php'); include 'Include/Footer.php'; Log_Hit("Translator"); ?> thanks in advance zainul Quote Link to comment https://forums.phpfreaks.com/topic/268106-language-translator/ Share on other sites More sharing options...
trq Posted September 7, 2012 Share Posted September 7, 2012 Awesome. We might need a little more information than you have provided. Quote Link to comment https://forums.phpfreaks.com/topic/268106-language-translator/#findComment-1375983 Share on other sites More sharing options...
the-botman Posted September 7, 2012 Author Share Posted September 7, 2012 sorry about that... ok see if i try and translate the word Love from english to Afrikaans this is what i get Translate: love English => Afrikaans Translation: lief and if i do the same for you i get Translate: you English => Afrikaans Translation: jy but when i try and translate love you i get 400. That?s an error. Your client has issued a malformed or illegal request. i hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/268106-language-translator/#findComment-1375999 Share on other sites More sharing options...
the-botman Posted September 7, 2012 Author Share Posted September 7, 2012 sorry here is a link to the site its running on www.bhawap.com/translator.php Quote Link to comment https://forums.phpfreaks.com/topic/268106-language-translator/#findComment-1376003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.