asifshaon / 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

How to specify format parameter for Google.Apis.Translate.v2 client #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I use "Google.Apis.Translate.v2" to translate the text.

The code I use to translate the text:
var service = new TranslateService { Key = googleKey };

string[] contantArr = new string[] { "Hallo Welt" };
TranslationsListResponse response = service.Translations.List(contantArr, 
"en").Fetch();

if (response.Translations != null && response.Translations.Count > 0)
{
string detectedLanguageKey = response.Translations[0].DetectedSourceLanguage;
translated = response.Translations[0].TranslatedText;
}

Unfortunately I can't find the way to specify "FORMAT" parameter.
Format could be TEXT, HTML.

I tried to find the answer somewhere on the forum, but had no luck. 

Is these possibility to specify "format" parameter for Google.Apis.Translate.v2 
.NET client?

Is Google team going to add this feature in a future?

thank you

regards,
Alex

Original issue reported on code.google.com by olrybc...@gmail.com on 10 Jan 2012 at 10:30

GoogleCodeExporter commented 9 years ago
The .List(..) operation returns a ListRequest object, which has several 
properties -- one of them is the "Format" property:

  http://docs.google-api-dotnet-client.googlecode.com/hg/docs/html/AllMembers_T_Google_Apis_Translate_v2_TranslationsResource_ListRequest.htm

In order to change the value of the property, you will have to change your code 
slightly:

  var request = service.Translations.List(contantArr, "en");
  request.Format = "...";
  TranslationsListResponse response = request.Fetch();

Hope this helps!

Original comment by mlinder...@gmail.com on 11 Jan 2012 at 1:55

GoogleCodeExporter commented 9 years ago
Thank you. It works.

Original comment by olrybc...@gmail.com on 11 Jan 2012 at 9:06