Stranger
Stranger

Reputation: 10631

How get the meaning of a word in all language using google translate?

How to get the meaning of a word in all language represented in english using google translate? For eg., If the input if Lion(English), then the output should be,

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

and so on.

Upvotes: 1

Views: 2085

Answers (1)

Alain
Alain

Reputation: 27250

Use the example from 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 gives you the information you seek.

I also recommend reading the documentation, since it's brief: code.google.com/apis/language/translate/v2/using_rest.html

Upvotes: 1

Related Questions