如果一切運作良好,突然不是那麼一種可能性是,你有你的翻譯服務提供商(其他一些配置被更改,添加新的MOD,更新了一些軟件)的問題。
是非常簡單的方法來檢查出你有問題 谷歌API V1 或者是別的地方。要檢查它只是請創建與此內容的新的PHP文件:
這個文件你可以找到 vBET 包在do-not-upload/tool s/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;
?>
如果您使用谷歌 API V2 使用此代碼 - 也該文件將被包括在我們的下一個版本:
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;
?>
把它上傳到你的服務器(你的論壇根),並把它在瀏覽器中的URL。如果一切正常,你會得到答案:
Code:
Starting transaltion test
Test result: {"responseData": {"translatedText":"Welcome"}, "responseDetails": null, "responseStatus": 200}
Test error:
正如你看到的錯誤沒有任何價值,並導致了狀態 200。這意味著:一切正常。
如果您在封鎖響應谷歌將看起來如下:
Code:
{"responseData": null, "responseDetails": "Suspected Terms of Service Abuse, please contact ajaxapis-support@google.com.", "responseStatus": 403}
如果你在哪裡受阻 - 谷歌剛剛寫的消息說。它將使我們找到原因,不知是不是搞錯了,也許你會改變一些東西更好地適應谷歌的服務條款。反正可以訪問谷歌容易回時,問題就解決了 
如果你有網絡問題,然後結果將是空的,錯誤會告訴你這是怎麼回事(即: 無法解析主機“ajax.googleapis.com”)。注意在這種情況下,它可以需要一段時間你會看到輸出(直到連接超時了)。
網絡問題的例子:
Code:
Starting translation test
Test result:
Test error: Failed to connect to 74.125.95.95: Network is unreachable
Connection time (ms): 70.96484375
你應該怎麼做?
首先:檢查防火牆沒有阻止訪問谷歌。
第二:你應該聯繫你的主機提供商,並要求他與連接有關的問題
如果你只看到“啟動翻譯測試”或什麼都沒有那麼很可能你沒有安裝 CURL模塊在你的PHP。
如果您使用的是微軟的API,創建新的PHP文件,並把它裡面的代碼。
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;
?>
上傳您的服務器上,在你的根論壇文件夾中,並把鏈接到您的瀏覽器。
您應該會看到這樣的事情:
PHP Code:
Starting translation test
Test result: "Hello"
Test error:
Connection time (ms): 272.083984375
如果出現錯誤則會發生錯誤,即如果你把 錯了微軟 ID:
PHP Code:
Starting translation test
Test result: "ArgumentException: Invalid appId Parameter name: appId xxx"
Test error:
Connection time (ms): 416.24194335938
你應該仔細粘貼您的Microsoft ID更多的時間
您還可以得到此錯誤消息 (帶有不同的 ID 值),這就意味著你是 微軟被阻止:
PHP Code:
Starting translation test MS
Test result: "InvalidOperationException: : ID=3641.V2_Json.Translate.365033CA"
Test error:
Connection time (ms): 237.756103516
在這種情況下,您將不得不將郵件發送到 microsoft 技術支援: mtcont@microsoft.com
包括這樣的內容:
微軟翻譯 API ID
-完整錯誤代碼,即: InvalidOperationException:: ID=3641.V2_Json.Translate.365033CA
描述問題, - 當它出現時,等