Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Tool for translating php

I need to translate all visible text in a php file

7:42 pm on Jun 25, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:July 28, 2004
votes: 0

Does there exist a tool, that can detect which text is dispayed in a php file, and which is code?

I need to translate text in php files, and would like an easier way than reading through it all, in every file.

Hope someone can help :)

5:49 pm on June 30, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:May 4, 2002
votes: 0

Hi there,

I had this problem a while back as well. This is what I did:

1. Create an output buffer and store the contents of the PHP output in a variable. (ob_start, ob_get_contents)

2. Strip all the html/css/javascript (strip_tags) out of the variable ensuring that you insert some form of delimiter in their place

3. Tokenise the variable using the delimiter and you will have all the 'text' bits of your php file.

4. You should then be able to replace each token in that particular PHP file with either its translated equivalent or a function call to retrieve the text.

You can include code at the start and end of your PHP files to perform this sub-processing. I used the above process successfully on a very large site which has now been successfully converted into multiple languages. Hope this helps.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members