Translate webpage of unlimited content using google translate.


I am working on a code where i need to convert the whole webpages with unlimited characters of content using google translate.

I know there is a limit of 2000 chars at a time for the conversion using google translate. but yet i need to implement this.

I have already achieved a target of translating unlimited content  using splitting the whole string in substrings and sending request to google translate using that substrings in a loop.

but now a new issue is generated in which if string contiains any html tags then in case of all the closed html tags in single string, I am geeting proper translation where as, when string splits and if at the time of splitting the string, any html tag remains unclosed, then from that place, whole string looses its format given using tags like <b>,<strong>,<td> etc. and whole translated text can not get the same HTML formating given in the same english(for ex.)  paragraph.

I am using google ajax api dll ( )  for setting the reference in vs 2005 and asp C# as my development environment.

plz help me as soon as possible as its very urgent and very imp for me to complete this task.

Thank you...
C# - Code Behind 

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Google.API;
using Google.API.Translate;

public partial class _Default : System.Web.UI.Page 

protected void btn_Click(object sender, EventArgs e)
        litFullPara.Text = Text;

        string Para = "<font color='Red'><b>Since the first computer was made in the late fifties,the technology has developed extremely. Computers which took the place of a living-room then, are now being made in creditcard-formats.</b> More and more areas are being taken over by the computer. As computers are capable of handling large amounts of data in a very short time, they are well suited for wordprocessing. I guess that it won't be long till all the paper-archives are replaced by magnetic tapes and diskettes. A diskette can contain much more data than a written page, and it takes less place! It is possible to get the Norwegian telephone book on just one diskette.</font>";

        int length = Para.Length;
        string Reply = "";
        string[] splitString = Para.Split('.');

        foreach (string word in splitString)
            if(word != "")
                Reply = Reply +" "+ Translator.Translate(word, Language.English, Language.Hindi, TranslateFormat.html) +". "; 


.ASPX code :-

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:Button ID="btn" Text="Click" runat="server" OnClick="btn_Click" /><br /><br />
    <asp:Literal ID="litFullPara" runat="server"></asp:Literal><br /><br />
    <asp:Literal ID="litSplitParas" runat="server"></asp:Literal>

Open in new window

Who is Participating?
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Can't you treat it as xml and translate textnodes only
YYatinAuthor Commented:
I can consider it in any way as per your instruction only...coz... i am completely unaware with  xml data reading...can you plz show me an example... thankx 4 the reply...
Michel PlungjanIT ExpertCommented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.