karishmal / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

specify both the source and the target language when translating #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Google Translate API v2

Hi,
How do I specify both the source and the target language with 
google-api-dotnet-client c#

Original issue reported on code.google.com by ssog...@gmail.com on 31 Oct 2011 at 9:46

GoogleCodeExporter commented 9 years ago
You can set the optional "Source" field by changing the .Source property on the 
Translations.ListRequest. See below for some example code:

var request =  service.Translations.List(translations, "<targetLanguage, e.g. 
en>");
request.Source = "<sourceLanguage, e.g. fr>";
response = request.Fetch();

foreach (TranslationsResource translation in response.Translations)
{
  Console.WriteLine("translation", translation.TranslatedText);
}

Original comment by mlinder...@gmail.com on 31 Oct 2011 at 11:48

GoogleCodeExporter commented 9 years ago
// the example code:
  $client = new apiClient();
  $client->setApplicationName ('Google Translate PHP Gavote Application');
  $client->setDeveloperKey (GAVOTE_GOOGLE_API_KEY);
  $service = new apiTranslateService($client);
  // NOW:
  $translations = $service->translations->listTranslations('Erde', 'en', array ('source' => 'de')); // last array parameter: source language!

Original comment by ral.die...@gmail.com on 23 Jan 2012 at 7:08