How to add Google translate in Desktop application in C#.

Опубликовано: 27 Июль 2026
на канале: IT Core Soft
5,669
66

link:
https://translate.googleapis.com/tran...{fromLanguage}&tl={toLanguage}&dt=t&q={HttpUtility.UrlEncode(input)}

google translate:
https://translate.google.com/?sl=en&t...


Download from this link:
https://github.com/hamza3344/googletr...
My fiverr link: https://www.fiverr.com/hamzakhalid178
My Upwork Profile: https://www.upwork.com/freelancers/~0...

Whatsapp Number: +923338672398

if you have any problem comment below. please like, share and subscribe the channel. Contact me on [email protected] if you need any custom software, website and mobile Application.

code


using System.Web;
using System.Net;

public String translate(String input, string from, string to)
{
var fromLanguage = from;
var toLanguage = to;
var url = $"https://translate.googleapis.com/tran...{fromLanguage}&tl={toLanguage}&dt=t&q={HttpUtility.UrlEncode(input)}";
var webclient = new WebClient
{
Encoding = System.Text.Encoding.UTF8
};
var result = webclient.DownloadString(url);
try
{
result = result.Substring(4, result.IndexOf("\"", 4
, StringComparison.Ordinal) - 4);
return result;
}
catch(Exception e1)
{
return "error";
}


}