/// <summary> /// Returns text translations from one language to another. /// Documentation https://developers.google.com/translate/v2/reference/translations/list /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated translate service.</param> /// <param name="q">The text to translate</param> /// <param name="target">The target language into which the text should be translated</param> /// <param name="optional">Optional paramaters.</param> /// <returns>TranslationsListResponseResponse</returns> public static TranslationsListResponse List(translateService service, string q, string target, TranslationsListOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (q == null) { throw new ArgumentNullException(q); } if (target == null) { throw new ArgumentNullException(target); } // Building the initial request. var request = service.Translations.List(q, target); // Applying optional parameters to the request. request = (TranslationsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Translations.List failed.", ex); } }
/// <summary> /// Detect the language of text. /// Documentation https://developers.google.com/translate/v2/reference/detections/list /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated translate service.</param> /// <param name="q">The text to detect</param> /// <returns>DetectionsListResponseResponse</returns> public static DetectionsListResponse List(translateService service, string q) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (q == null) { throw new ArgumentNullException(q); } // Make the request. return(service.Detections.List(q).Execute()); } catch (Exception ex) { throw new Exception("Request Detections.List failed.", ex); } }