public async Task <string> GetTranslatedText(string text, string from, string to) { var service = new TranslateService( new BaseClientService.Initializer { ApiKey = _translatorsSettings.Items.Find(i => i.Vendor.ToLower() == Vendors.Google)?.SubscriptionKey }); var client = new TranslationClientImpl(service); var response = await client.TranslateTextAsync(text, to, from); return(response.TranslatedText); }
public async Task <IEnumerable <GeneralizationResponse> > UnifyContent(IEnumerable <string> contentEntries) { var result = new List <GeneralizationResponse>(); foreach (var text in contentEntries) { var translated = await _client.TranslateTextAsync(text, "en"); result.Add(new GeneralizationResponse { OriginId = Guid.NewGuid().ToString("N"), Origin = translated.OriginalText, Unified = translated.TranslatedText }); } return(result); }