homepage Welcome to WebmasterWorld Guest from 23.23.8.131
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
TechMan

5+ Year Member



 
Msg#: 4259360 posted 10:46 am on Jan 28, 2011 (gmt 0)

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

 

Wittner

5+ Year Member



 
Msg#: 4259360 posted 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?

cheers,

Wittner

TechMan

5+ Year Member



 
Msg#: 4259360 posted 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?

Wittner

5+ Year Member



 
Msg#: 4259360 posted 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