1

如何使用谷歌翻译获得以英语表示的所有语言的单词的含义?例如,如果输入是 Lion(English),那么输出应该是,

leon(Spanish)
lion(French)
singam(Tamil)
simhah(Hindi)

等等。

4

1 回答 1

1

使用此处的示例:

<?php
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiTranslateService.php';

$client = new apiClient();
$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 apiTranslateService($client);

$langs = $service->languages->listLanguages();
print "<h1>Languages</h1><pre>" . print_r($langs, true) . "</pre>";

$translations = $service->translations->listTranslations('Hello', 'hi');
print "<h1>Translations</h1><pre>" . print_r($translations, true) . "</pre>";

listTranslations为您提供所需的信息。

我还建议阅读文档,因为它很简短:code.google.com/apis/language/translate/v2/using_rest.html

于 2012-04-10T18:27:30.990 回答