private static string TranslateTweet(dynamic nonEnglishTweet) { if (!HasDynamicProperty(nonEnglishTweet, "lang")) { throw new Exception("\"lang\" property doesn't exist!"); } string textToTranslate = GetTweetText(nonEnglishTweet); string detectedLanguage = nonEnglishTweet.lang; string clientId = "Project_TranslateTwitter"; string clientSecret = Environment.GetEnvironmentVariable( "Project_TranslateTwitter.ClientSecret", EnvironmentVariableTarget.User); var authenticationContext = new Translator.Microsoft.Auth.AuthenticationContext(clientId, clientSecret); var translator = new TranslatorCommand(authenticationContext, new LanguageTranslatorArg(textToTranslate, detectedLanguage)); translator.Execute(); var translatedText = translator.Result; return(translatedText); }
private static string TranslateTweet(dynamic nonEnglishTweet) { if (!HasDynamicProperty(nonEnglishTweet, "lang")) throw new Exception("\"lang\" property doesn't exist!"); string textToTranslate = GetTweetText(nonEnglishTweet); string detectedLanguage = nonEnglishTweet.lang; string clientId = "Project_TranslateTwitter"; string clientSecret = Environment.GetEnvironmentVariable( "Project_TranslateTwitter.ClientSecret", EnvironmentVariableTarget.User); var authenticationContext = new Translator.Microsoft.Auth.AuthenticationContext(clientId, clientSecret); var translator = new TranslatorCommand(authenticationContext, new LanguageTranslatorArg(textToTranslate, detectedLanguage)); translator.Execute(); var translatedText = translator.Result; return translatedText; }