Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
How to convert text english to hindi using c# in windows Application? by creating a custom font or code ?

Regards
Swapnil BAdgujar
Posted

Try google[^] for ideas on how to get started.
 
Share this answer
 
using System;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;

namespace Utilities
{
public static class Translator
{
///
/// Translates the text.
///

/// <param name="input" />The input.
/// <param name="languagePair" />The language pair.
/// <returns>
public static string TranslateText(string input, string languagePair)
{
return TranslateText(input, languagePair, System.Text.Encoding.UTF7);
}

///
/// Translate Text using Google Translate
///

/// <param name="input" />The string you want translated
/// <param name="languagePair" />2 letter Language Pair, delimited by "|".
/// e.g. "en|da" language pair means to translate from English to Danish
/// <param name="encoding" />The encoding.
/// <returns>Translated to String
public static string TranslateText(string input, string languagePair, Encoding encoding)
{
string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", input, languagePair);

string result = String.Empty;

using (WebClient webClient = new WebClient())
{
webClient.Encoding = encoding;
result = webClient.DownloadString(url);
}

Match m = Regex.Match(result, "(?<=
)(.*?)(?=
)");

if (m.Success)
result = m.Value;

return result;
}
}
}
 
Share this answer
 
Comments
Richard MacCutchan 27-Jun-15 9:00am    
Please use <pre> tags round your code, to make it readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900