C# Google Translate – Basit Metin Çevirme

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;
}
}
}

Düşüncesiz Adam

sizleri düşünmeyip buraya hiçbir şey yazmadım !

You may also like...

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.

Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.