views:

149

answers:

1

I'm looking to translate a webpage in PHP 5 so I can save the translation and make it easily accessible via mydomain.com/lang/fr/category/article.html rather than users having to go through google translate.

I've found various easy ways to translate text via CURL, however what i'd really like to be able to do is translate an entire webpage but obviously ignore the tags.

The problem is that Google Translate messes up all the HTML tags, class names etc

Does anyone know of a php class that can translate an entire webpage whilst ignoring the tags?

I'm guessing it may be possible via advanced regular expressions or something like that, but i'm not sure.

I can't just curl Google's response as i'll have all the extra JS that they put in.

Any ideas?

+3  A: 

I know it's not quite what you asked for, but a much simpler alternative would just be to include the free Google Translate widget on all your pages. That way visitors select the language they would like to view the site in and Google dynmaically does the rest (and persists their selection throughout the site). You then don't need to worry about trying to create and keep updated dozens of different HTML files for every page, each with it's own set of internal links (which, frankly, sounds like a nightmare to maintain).

Dan Diplo