【问题标题】:How get the meaning of a word in all language using google translate?如何使用谷歌翻译获得所有语言中单词的含义?
【发布时间】:2012-04-10 18:09:54
【问题描述】:

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

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

等等。

【问题讨论】:

  • 来自:code.google.com/apis/language/translate/v2/getting_started.html “Google Translate API v2 现在仅作为付费服务提供,您的应用程序每天可以发出的请求数量是有限的。”你愿意为 API 付费吗?如果没有,你不妨关闭这个问题。
  • 没关系阿兰,我准备付款了
  • 好的,接下来 - 你使用什么编程语言。您尚未使用任何语言标记您的问题。答案会有所不同,具体取决于您使用的是 C++、C#、Java、VB.Net、Go、Google Web Toolkit、JavaScript、Objective C、PHP、Python 还是 Ruby。
  • 我打算用PHP实现

标签: php google-translate


【解决方案1】:

使用here中的示例:

<?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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-19
    • 1970-01-01
    • 1970-01-01
    • 2013-08-03
    • 2018-08-01
    • 2012-11-08
    相关资源
    最近更新 更多