Ní Má bhí gach rud ag obair go maith agus go tobann tá sé sin ar cheann fhéidearthacht go bhfuil tú gceist le do sholáthraí aistriúchán (daoine eile iad: Rinneadh athrú ar chumraíocht éigin, mod nua isteach, a roinnt bogearraí suas chun dáta).
Tá an-bealach éasca a sheiceáil amach atá agat leis an tsaincheist Google API v1 nó go bhfuil sé áit éigin eile. Chun seiceáil le do thoil é a bheith cóir a chruthú comhad php nua leis an ábhar seo:
Comhad seo is féidir leat teacht i vBET pacáiste i do-not-upload/tools/googletest.php
PHP Code:
<?php
echo "Starting translation test for Google API v1<br/>\n";
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&format=html&langpair=pl|en&q=witaj');
curl_setopt($connection, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)');
//curl_setopt($connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$time = microtime(true) * 1000;
$result = curl_exec($connection);
$time = microtime(true) * 1000 - $time;
echo 'Test result: '.$result."<br/>\n";
echo 'Test error: '.curl_error($connection)."<br/>\n";
curl_close($connection);
echo 'Connection time (ms): '.$time;
?>
Sa chás go n-úsáideann tú google API v2 seo a úsáid cód - chomh maith beidh an comhad seo a chur san áireamh in ár scaoileadh chugainn:
PHP Code:
<?php
require_once('./global.php');
echo "Starting translation test for Google API v2<br/>\n";
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, 'https://www.googleapis.com/language/translate/v2?key='.$vbulletin->options['vbenterprisetranslator_googleapikeyv2'].'&format=html&q=witaj&target=en');
curl_setopt($connection, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)');
//curl_setopt($connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$time = microtime(true) * 1000;
$result = curl_exec($connection);
$time = microtime(true) * 1000 - $time;
echo 'Test result: '.$result."<br/>\n";
echo 'Test error: '.curl_error($connection)."<br/>\n";
curl_close($connection);
echo 'Connection time (ms): '.$time;
?>
É a uaslódáil chuig do fhreastalaí (do fréimhe fóram) agus an URL a chur air i do bhrabhsálaí. Má tá gach rud ceart go leor gheobhaidh tú freagra:
Code:
Starting transaltion test
Test result: {"responseData": {"translatedText":"Welcome"}, "responseDetails": null, "responseStatus": 200}
Test error:
Mar a fheiceann tú earráid bhfuil aon luach agus mar thoradh ar stádas 200. Ciallaíonn sé seo: Tá gach rud ceart go leor.
Beidh Breathnaíonn Má tá tú i gcás bac freagra ó Google mar sin:
Code:
{"responseData": null, "responseDetails": "Suspected Terms of Service Abuse, please contact ajaxapis-support@google.com.", "responseStatus": 403}
Má tá tú i gcás bac - scríobh ach go Google mar a deir an teachtaireacht. Ligfidh sé a aimsiú ar ár ar an gcúis sin, b'fhéidir go bhfuil sé roinnt botún, b'fhéidir go mbeidh ort rud éigin a athrú ionas go luífidh sé níos fearr a TOS Google. Mar sin féin tugann Google éasca teacht ar ais nuair a bhfuil an cheist réitithe 
Má tá tú fhadhb líonra ansin beidh toradh a bheith folamh agus beidh earráid a insint duit cad tá ar siúl (is é sin: Níorbh fhéidir a réiteach óstach 'ajax.googleapis.com'). Tabhair faoi deara i gcás den sórt sin is féidir é a tamall sula feicfidh tú aschur (go dtí go bhfuil nasc amaithe suas).
Líonra fhadhb shampla:
Code:
Starting translation test
Test result:
Test error: Failed to connect to 74.125.95.95: Network is unreachable
Connection time (ms): 70.96484375
Cad ba cheart duit a dhéanamh?
gcéad dul síos: seiceáil nach mbaineann an balla dóiteáin bloc rochtain a google.
sa dara háit: Ba chóir duit dul i dteagmháil le do sholáthraí óstach agus é a iarraidh maidir le fadhb le ceangal
Má fheiceann tú ach "Ag tosú scrúdú aistriúcháin" nó rud ar bith ar chor ar bith ansin is dócha nach bhfuil tú bhfuil suiteáilte curl modúl i do PHP.
Má tá tú ag baint úsáide as Microsoft API, a chruthú comhad nua a php agus an cód a chur taobh istigh air.:
PHP Code:
<?php
require_once('./global.php');
echo "Starting translation test MS<br/>\n";
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, 'http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId='.$vbulletin->options['vbenterprisetranslator_microsoftappid'].'&from=pl&to=en&options={%22ContentType%22:%22text/html%22}&text=witaj');
curl_setopt($connection, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)');
//curl_setopt($connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$time = microtime(true) * 1000;
$result = curl_exec($connection);
$time = microtime(true) * 1000 - $time;
echo 'Test result: '.$result."<br/>\n";
echo 'Test error: '.curl_error($connection)."<br/>\n";
curl_close($connection);
echo 'Connection time (ms): '.$time;
?>
Ná mar a uaslódáil ar do fhreastalaí, i do fhillteán fóram fréimhe, agus go bhfuil nasc chur isteach i do bhrabhsálaí.
Ba chóir duit a fheiceáil rud éigin mar seo:
PHP Code:
Starting translation test
Test result: "Hello"
Test error:
Connection time (ms): 272.083984375
Má tharlaíonn rud éigin mícheart gheobhaidh tú botún, is é sin má chuir tú mícheart Microsoft ID:
PHP Code:
Starting translation test
Test result: "ArgumentException: Invalid appId Parameter name: appId xxx"
Test error:
Connection time (ms): 416.24194335938
Ná mar ba chóir duit a ghreamú ar do Microsoft id go cúramach amháin níos mó ama
Is féidir leat freisin an teachtaireacht earráide (le luach ID éagsúla), rud a chiallaíonn go bhfuil tú bac Microsoft:
PHP Code:
Starting translation test MS
Test result: "InvalidOperationException: : ID=3641.V2_Json.Translate.365033CA"
Test error:
Connection time (ms): 237.756103516
Sa chás seo, beidh ort ríomhphost a sheoladh chun tacú le Microsoft: mtcont@microsoft.com
lena n-áirítear ábhar seo:
-Do Microsoft aistritheoir API id
-Iomlán cód earráid is cúis leis, is é sin: InvalidOperationException:: ID = 3641.V2_Json.Translate.365033CA
-Cur síos ar an bhfadhb, - nuair a dhealraíonn sé, etc