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 (http://iron9light.wordpress.com/2008/06/03/google-translate-api-for-net-01-release/
) 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.
C# - Code Behind
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<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>