homepage Welcome to WebmasterWorld Guest from 54.234.0.85
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

    
Tool for translating php
I need to translate all visible text in a php file
Kongen

10+ Year Member



 
Msg#: 3378562 posted 7:42 pm on Jun 25, 2007 (gmt 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 :)

 

dublinmike

10+ Year Member



 
Msg#: 3378562 posted 5:49 pm on Jun 30, 2007 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
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