public TranslationLanguageInfo[] GetSourceLanguages(string appID, string appID2) { if (_sourceLanguages == null) { var result = new List <TranslationLanguageInfo>(); var json = makeRestCallPost( appID, @"https://www.googleapis.com/language/translate/v2/languages", new List <MyTuple <string, string> >()); // -- var nodes = json.SelectNodes(@"/root/data/languages/language"); if (nodes != null) { // ReSharper disable LoopCanBeConvertedToQuery foreach (XmlNode xmlNode in nodes) // ReSharper restore LoopCanBeConvertedToQuery { var languageCode = xmlNode.InnerText; var ci = BingSoapTranslationEngine.IntelligentGetCultureInfo(languageCode); if (ci != null) { result.Add( new TranslationLanguageInfo { LanguageCode = languageCode, UserReadableName = ci.DisplayName, }); } } } _sourceLanguages = result.ToArray(); } return(_sourceLanguages); }
public string MapCultureToDestinationLanguageCode(string appID, string appID2, CultureInfo cultureInfo) { return(BingSoapTranslationEngine.DoMapCultureToLanguageCode(GetDestinationLanguages(appID, appID2), cultureInfo)); }