C# Google Translate - Basit Metin Çevirme
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
namespace ConsoleApplication1
{
class Program
{
private static void Main(string[] args)
{
string cevirilecekMetin = "my name ahmet";
string cevirilecekDiller = "en|tr";
string ceviri = Translate(cevirilecekMetin, cevirilecekDiller);
Console.WriteLine(ceviri);
Console.ReadKey();
}
public static string Translate(string input, string languagePair)
{
string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", input, languagePair);
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.GetEncoding("ISO-8859-9");
string result = webClient.DownloadString(url);
result = result.Substring(result.IndexOf("<span title=\"") + "<span title=\"".Length); result = result.Substring(result.IndexOf(">") + 1);
result = result.Substring(0, result.IndexOf("</span>"));
result = HttpUtility.HtmlDecode(result.Trim());
return result;
}
}
}