public static string TranslateText(string Text, string tragetlan, string sourceLang) { try { LanguagesListResponse ls = new LanguagesListResponse(); Google.Apis.Translate.v2.Data.LanguagesResource ss = new Google.Apis.Translate.v2.Data.LanguagesResource(); ss.Language = tragetlan; // GetLanguageCode string googlekey = "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxw"; var service = new TranslateService(new BaseClientService.Initializer() { ApiKey = googlekey }); //new TranslateService { Key = googlekey }; ICollection<string> data = new Collection<string>(); string[] srcText = new[] { Text }; TranslationsListResponse response = service.Translations.List(srcText, tragetlan).Fetch(); var translations = new List<string>(); // We need to change this code... // currently this code foreach (Google.Apis.Translate.v2.Data.TranslationsResource translation in response.Translations) { translations.Add(translation.TranslatedText); } return translations[0]; } catch (Exception ex) { return Text; } }
Increase quota of Google Translator API by increasing characters/second/user Limit. Steps to go to this page: 1. Login to Google 2. Go to url : code.google.com/apis/console 3. Click on Quotas 4. Increase Translate API Quote Up to 100000
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)