OmegaT: Translating php files
Thread poster: lbc2002
lbc2002
lbc2002
Local time: 21:07
English to Italian
Oct 7, 2008

Hello everybody!

I have been translating several HTML files with OmegaT without any trouble. By the way, congratulations on this excellent, free tool!
Now I have some php files and, if possible, I would like to use OmegaT as well.
As these files are basically HTML files with just some (say, "a little") php code "embedded" inside (tipically at the top and the bottom of all the pages, I suppose in order to insert a common website header/footer, for example: "[... php code
... See more
Hello everybody!

I have been translating several HTML files with OmegaT without any trouble. By the way, congratulations on this excellent, free tool!
Now I have some php files and, if possible, I would like to use OmegaT as well.
As these files are basically HTML files with just some (say, "a little") php code "embedded" inside (tipically at the top and the bottom of all the pages, I suppose in order to insert a common website header/footer, for example: "[... php code ...] HTML code [ ... php code ... ]"), I have tried adding "php" to the supported OmegaT "HTML" file format list ("file filters") and this way everything seems actually to work properly.

Unfortunately, when I create the target documents, OmegaT seems to encode all the PHP start/end code " < ?" and ">" and whatever "" within the php blocks (such as in arrays, functions etc.) using their HTML equivalent code (i.e.: &theampersand lt; and &theampersand gt;. Of course, please replace "&theampersand" with the usual correct symbol, I have put it due to the forum post conversion).

I would greatly appreciate it if anybody could suggest a work-around, of course if it is possible.

Thanks in advance!

Lucio

PS: please delete the duplicated post. I had to post it again after some changes to the message body.
Collapse


 
Didier Briel
Didier Briel  Identity Verified
France
Local time: 21:07
English to French
+ ...
Using a little search and replace Oct 7, 2008

lbc2002 wrote:
Now I have some php files and, if possible, I would like to use OmegaT as well.
As these files are basically HTML files with just some (say, "a little") php code "embedded" inside (tipically at the top and the bottom of all the pages, I suppose in order to insert a common website header/footer, for example: "
code ...] HTML code [ ... php code ... ]"), I have tried adding "php" to the supported OmegaT "HTML" file format list ("file filters") and this way everything seems actually to work properly.

Unfortunately, when I create the target documents, OmegaT seems to encode all the PHP start/end code " < ?" and ">" and whatever "" within the php blocks (such as in arrays, functions etc.) using their HTML equivalent code (i.e.: &theampersand lt; and &theampersand gt;. Of course, please replace "&theampersand" with the usual correct symbol, I have put it due to the forum post conversion). [/quote]
If all you need is to ignore the PHP content, there's a rather usable workaround.
Before translation, replace <? markers with <!--?, and ?> markers with ?-->, using for instance a text editor.

This way, everything PHP will be considered as comments, and will not be changed (and will not appear for translation).

When the translation is finished, replace <!--? with <?, and ?--> with ?>, and that's it.

Of course, doing these replacements can be tedious if you have a lot of files, but that could be automated using scripts or macros.

Didier Briel


[Edited at 2008-10-07 15:42]


 
Robert Tucker (X)
Robert Tucker (X)
United Kingdom
Local time: 20:07
German to English
+ ...
Strings inside PHP Oct 8, 2008

Didier Briel wrote:
If all you need is to ignore the PHP content, there's a rather usable workaround.
Before translation, replace markers with ?-->, using for instance a text editor.

This way, everything PHP will be considered as comments, and will not be changed (and will not appear for translation).


There may be a number of translatable strings within the PHP tags though, e.g. something like

<?php comments_number('no comment','1 comment','% comments'); ?>

where "no comment", "1 comment" and "comments" all need translating.

(Example taken from a WordPress theme file.)

[Edited at 2008-10-08 06:21]


 


There is no moderator assigned specifically to this forum.
To report site rules violations or get help, please contact site staff »


OmegaT: Translating php files






Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »
TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »