//function that will be called to attempt to determine the from languange if none is given. private void DetectLanguage(string input) { try { Regex reg = new Regex(@"language"".""(?<languageCode>[^""]+)"); string url = String.Format("http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q={0}", input); WebGrabber webGrabber = new WebGrabber(url); webGrabber.GetResponse(); string result = webGrabber.GetString(); Match match = reg.Match(result); string matched = match.Groups["languageCode"].Value; _fromLanguage = LanguageUtility.GetLanguage(matched); if (_debug) { logger.Debug("Translation tool: Detect Language: Source: {0} : Detected Language: {1}", result, LanguageUtility.ToString(_fromLanguage)); } } catch (Exception e) { if (e is ThreadAbortException) { throw e; } _fromLanguage = LanguageUtility.GetLanguage("en"); } }
private void BuildLanguagePair() { //builds url encoded language pare for translation eg: en|es for English to Spanish _strLanguagePare = LanguageUtility.GetLanguageCode(_fromLanguage) + "%7C" + LanguageUtility.GetLanguageCode(_toLanguage); if (_debug) { logger.Debug("Translation tool: Language Pair: {0}", _strLanguagePare); } }