You must Sign In to post a response.
  • Category: .NET

    Translate html string into another language in win app c#

    Hi,
    I am developing a win form application in C#.
    I have a random html string in Russian language containing whole page data and writing it into a html file. I need to convert/translate it into english.
    Help me how can i do this.

    I can't hard code few words in resource file as those data will be random.

    Thanks
    Anil
  • #767825
    well I am not so expert in translation area but what you want to do is, first create a map with Russian words with endglish words and then use them for translation see below code snippet

    var map = new Dictionary<char, string>
    {
    { '?', "P" },
    { '?', "e" },
    { '?', "t" },
    { '?', "r" },
    ...
    }

    var result = string.Concat("?????????".Select(c => map[c]));

    OR you can use 'Google Releases Language Translation API' see below link
    http://www.programmableweb.com/news/google-releases-language-translation-api/2008/03/20

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #767832
    Hi,

    I tried with below URL but it translating only small string but not a big whole html page content.

    string url = string.Format("https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}", "ru", "en", HttpUtility.UrlEncode(sourceText));

    Please advise.

    anil jain,
    Software Developer,
    NEITL,Mumbai.

  • #767834
    If you're using Windows 7, you can take advantage of the new ELS (Extended Linguistic Services) API, which provides transliteration functionality for you. Have a look at the Windows 7 API Code Pack - it's a set of managed wrappers on top of many new API in Windows 7 (such as the new Taskbar). Look in the Samples folder for the Transliterator example, you'll find it's exactly what you're looking for:

    http://stackoverflow.com/questions/3079388/how-can-i-convert-cyrillic-string-into-english-in-c-sharp


Sign In to post your comments