我正在使用Google翻译API,它会从“πανθαυμαστε”返回翻译“panthafmaste”。有没有什么方法可以让我得到一个空值,以便我知道这个单词没有被翻译?
我尝试检测语言,但精度始终返回为“1”和“isReliable = false”。也许可以通过谷歌进行音译并进行比较,但我发现它已被弃用。
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_TranslateService.php';
$client = new Google_Client();
$client->setApplicationName('Google Translate PHP Starter Application');
// Visit https://code.google.com/apis/console?api=translate to generate your
// client id, client secret, and to register your redirect uri.
// $client->setDeveloperKey('insert_your_developer_key');
$service = new Google_TranslateService($client);
$translations = $service->translations->listTranslations($word, $this->google_translate_to,Array('source'=>$this->google_translate_language));//$this->google_translate_to);