homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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

 10:46 am on Jan 28, 2011 (gmt 0)


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!?




 9:46 am on Feb 2, 2011 (gmt 0)

Can you take all the html tags out of the page strip_tags() before submitting the page? Does G need to have the tags in place?




 10:48 am on Feb 2, 2011 (gmt 0)

But then how will I place translated text back into those tags so I can display page?


 12:00 pm on Feb 2, 2011 (gmt 0)

Ah, I didn't realise you were going to redisplay the HTML back to the user.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved