Translate webpage of unlimited content using google translate.

Posted on 2009-12-25
Last Modified: 2012-06-21

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

Question by:YYatin
    LVL 75

    Accepted Solution

    Can't you treat it as xml and translate textnodes only
    LVL 3

    Author Comment

    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...
    LVL 75

    Expert Comment

    by:Michel Plungjan

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    Title # Comments Views Activity
    Web Api - how to handle key=value pairs in POST 13 95
    disabled AD accounts info 3 53
    jQuery Generalization 3 39
    exchange, scripts 3 34
    I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
    In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now