Jump to content

How to break page into 5000 chars piece for Google translation?


Recommended Posts

Hi,

 

I am trying to translate a page in PHP using Google API. There is 5000 chars limit on data that you can send to Google at a time. So I am trying to break the page into pieces of 5000 chars. But as you know while doing this we have to keep in mind the HTML formatting that it should not be disturbed otherwise you will not get desired results.

 

For example you have to send this:

 

<a href="#" class="myclass">Link</a>

 

Instead of this:

 

<a href="#" class="myclas

 

I am able to solve it somehow (although not perfectly I guess) by checking if "<" sign is coming after ">" sign or not. If "<" sign is coming after ">" then I go back to the point where I found ">" and cut string from there.

 

Anyway the point is I am still having some problems regarding HTML formatting and want to know how to do it efficiently. Is there any parser available that will solve this problem!?

 

Thanks

You mean like this  http://www.wizecho.com/

 

Not exactly because when of my requirement is that the HTML source code when viewed in browser should display that translated language for SEO purpose. What they are doing is converting text after it is displayed in browser. I want to translate before something is displayed on page and only translated content is displayed rather than first displaying English content and then translating to other language.

 

But what ever their technique is, I want to know how to break HTML in 5000 characters properly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.