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

  • #768029
    Hi,

    I tried to understand ELS but didn't got it.
    Will you please provide me any sample code for translation.

    Meanwhile i also tried with bing microsoft api but the problem with this is that per transaction its limit is 10000 charactor and my html file is more than 30k charactor and if i tried to break it and pass 10000 charator to bing api then its adding extra tag at the end in my html.

    Please suggest me if any free api solution for my problem.

    Thanks

    anil jain,
    Software Developer,
    NEITL,Mumbai.


  • Sign In to post your comments