Can any CAT handle PHP files?
Thread poster: suppster

suppster
Local time: 04:46
Mar 31, 2011

I've read on the forums that Deja Vu and Catscradle can import PHP files and present only what needs to be translated. However, the reports have been sketchy, with some having poor results with these tools. There is also PrepTags. Can any of these tools definitely deal with PHP files?

 

Samuel Murray  Identity Verified
Netherlands
Local time: 05:46
Member (2006)
English to Afrikaans
+ ...
No Mar 31, 2011

suppster wrote:
Can any of these tools definitely deal with PHP files?


No. The reason for that is that there is no "standard" PHP file. It is entirely up to the programmer or web designer to decide how to mark up translatable text. So every PHP job is unique.


 

suppster
Local time: 04:46
TOPIC STARTER
filter for Trados Mar 31, 2011

Would it be possible then to create a filter for Trados? Apparently, 'In TagEditor, you can set tags of special PHP/HTML codes in DTD setting file (*.ini format).' If so would this need to be created separately for each PHP project, or could one filter work for all PHP files?

This thread also says this can be done:
http://mac.proz.com/forum/l
... See more
Would it be possible then to create a filter for Trados? Apparently, 'In TagEditor, you can set tags of special PHP/HTML codes in DTD setting file (*.ini format).' If so would this need to be created separately for each PHP project, or could one filter work for all PHP files?

This thread also says this can be done:
http://mac.proz.com/forum/localization/29390-php_localisation:_dtd_settings.html



[Edited at 2011-03-31 12:20 GMT]
Collapse


 

starspain
Spain
Local time: 05:46
Member (2003)
Spanish to German
+ ...
Transit can Mar 31, 2011

Hello Suppster, Transit can handle PHP files (and in fact any tagged text file format), but it might be necessary to adjust the file format definition to correctly protect the PHP tags because of what Samuel said, the possible customization of PHP files. Regards, Michael

suppster wrote:

Would it be possible then to create a filter for Trados? Apparently, 'In TagEditor, you can set tags of special PHP/HTML codes in DTD setting file (*.ini format).' If so would this need to be created separately for each PHP project, or could one filter work for all PHP files?

This thread also says this can be done:
http://mac.proz.com/forum/localization/29390-php_localisation:_dtd_settings.html



[Edited at 2011-03-31 12:20 GMT]


 

Thomas Johansson  Identity Verified
Peru
Local time: 23:46
English to Swedish
+ ...
just a few notes on PHP Mar 31, 2011

PHP files usually contain a mixture of two things: portions of HTML (or similar markup) and portions of PHP code proper.

As for the HTML portions of a PHP file, I assume that if you have a tool that can process HTML, then you could probably use it to process the HTML portions of a PHP file as well. (Perhaps try this: replace the .php file extension with .html, and see if your tool will process it. You may need to take measures for the tool not to touch the PHP portions inside the fi
... See more
PHP files usually contain a mixture of two things: portions of HTML (or similar markup) and portions of PHP code proper.

As for the HTML portions of a PHP file, I assume that if you have a tool that can process HTML, then you could probably use it to process the HTML portions of a PHP file as well. (Perhaps try this: replace the .php file extension with .html, and see if your tool will process it. You may need to take measures for the tool not to touch the PHP portions inside the file.)

As for the PHP code proper, it is a scripting language and doesn't use tags similar to those of HTML. The only thing that could possibly be called tags here would be the PHP start and end tags, which indicate where the PHP code starts and ends respectively. (Sorry, this form doesn't allow for insertion of these PHP tags, so I cannot show them here.)
Inside such PHP code, any text that might be relevant for translation would be in the form of so-called strings, which are strings of characters enclosed by double or single quotes. (However, one needs to be careful here, because some such strings might just be used for the internal code and should not be translated.)
Anyway, in general, when building a PHP site intended for publication in more than one language, you try to avoid including textual content in the PHP code itself (i.e. as strings as per above). Instead, you use identifiers and draw the text snippets from an external resource, such as a database or data file, or use some similar method - i.e. all translatable content in this case would be in a database or a data file separate from the PHP file itself.

Overall, my guess is that if you have a PHP file that you've been asked to translate, you probably just need to focus at the HTML portions themselves. And use a tool that can process HTML.

[Edited at 2011-03-31 18:50 GMT]

[Edited at 2011-03-31 18:51 GMT]

[Edited at 2011-03-31 18:53 GMT]
Collapse


 

Thomas Johansson  Identity Verified
Peru
Local time: 23:46
English to Swedish
+ ...
true, but Mar 31, 2011

Samuel Murray wrote:

suppster wrote:
Can any of these tools definitely deal with PHP files?


No. The reason for that is that there is no "standard" PHP file. It is entirely up to the programmer or web designer to decide how to mark up translatable text. So every PHP job is unique.


True, every PHP job and file is unique.

But still all translatable text in a PHP file will either be in the form of HTML (with corresponding HTML tags) or in the form of PHP strings (which are characterized by being enclosed within double or single quotes).

So, for a tool to work, it just needs to be able to either recognize HTML tags or, when inside PHP code proper, recognize any strings enclosed within such quotes.


 

Heinrich Pesch  Identity Verified
Finland
Local time: 06:46
Member (2003)
Finnish to German
+ ...
Trust your eyes only Apr 1, 2011

Its years since I translated php. I used Wordfast Classic and forced segmentation. So you really know each time that you are translating only the right strings.

 

John Fossey  Identity Verified
Canada
Local time: 23:46
Member (2008)
French to English
+ ...
Tagging a php file with strings Jan 23

I have been given a series of .php files in which the strings (hundreds of them) are in a standard format such as:

'alert_phone_null' => 'Il semble que vous n’ayez pas encore entré de numéro de téléphone cellulaire.',

It seems to me that there should be a regex (such as in MemoQ Regex tagger) that could extract the string to be translated and leave the rest as a CAT tag.

Does anyone know how to do this?


 

Jean Dimitriadis  Identity Verified
France
Local time: 05:46
Member
English to French
+ ...
You could use Memsource for a round trip Jan 23

Hello John,

I know Memsource offers a PHP filter. Just tested your string in a sample PHP file and the source segment it returned was stripped as you would expect:

Il semble que vous n’ayez pas encore entré de numéro de téléphone cellulaire.

You can enjoy a 30-day free trial, but if you have already done so in the past, you'll need a monthly subscription (the free version only allows two files at a time, so it's out of question for the job you
... See more
Hello John,

I know Memsource offers a PHP filter. Just tested your string in a sample PHP file and the source segment it returned was stripped as you would expect:

Il semble que vous n’ayez pas encore entré de numéro de téléphone cellulaire.

You can enjoy a 30-day free trial, but if you have already done so in the past, you'll need a monthly subscription (the free version only allows two files at a time, so it's out of question for the job you describe).

You should be able to use Memsource for round trip purposes (bilingual files creation and final export to php format), but still complete the bulk of the translation in MemoQ.

This could be of help: https://help.memsource.com/hc/en-us/articles/360001190792-What-is-the-Best-way-to-Process-Memsource-MXLIFF-Files-in-MemoQ-

Jean

P.S. Smartcat also supports PHP files, but a quick test produced an error, so it was inconclusive. It also allows you to Export Xliff files and reimport them, so it is also suitable for a round trip.

[Edited at 2019-01-23 16:33 GMT]
Collapse


 

SDL Community  Identity Verified
United Kingdom
Local time: 05:46
Member (1970)
English
You could also use Trados Jan 23

John Fossey wrote:

I have been given a series of .php files in which the strings (hundreds of them) are in a standard format such as:

'alert_phone_null' => 'Il semble que vous n’ayez pas encore entré de numéro de téléphone cellulaire.',

It seems to me that there should be a regex (such as in MemoQ Regex tagger) that could extract the string to be translated and leave the rest as a CAT tag.

Does anyone know how to do this?


Interestingly a very similar question came up today in the SDL Community. Response contains a file very similar to yours and an appropriate filetype you could adapt very easily for your file. Simple enough:

https://community.sdl.com/product-groups/translationproductivity/f/90/t/21214


 

Stanislav Okhvat
Local time: 07:46
English to Russian
Re: Tagging a php file with strings Feb 15

Hello John,

Actually, you can use something as simple as Microsoft Word to hide everything except specific text which is within these quotation marks. TransTools+ (http://www.translatortools.net/transtoolsplus-hideunhide.html) contains a tool called Hide/Unhide Text (http://ww
... See more
Hello John,

Actually, you can use something as simple as Microsoft Word to hide everything except specific text which is within these quotation marks. TransTools+ (http://www.translatortools.net/transtoolsplus-hideunhide.html) contains a tool called Hide/Unhide Text (http://www.translatortools.net/transtoolsplus-hideunhide.html) which can hide everything that does not match a specific regular expression. The regular expression settings for this purpose are:

Options:
Hide everything except specific text
Hide by text or regular expressions

Add an item to the list

Type:
Regex

Find What:
['"][^'"]+['"]\s*=>\s*(["'])((?:(?=(\\?))\3.)*?)\1

Options:
Find capturing group instead of the full regular expression match
Group 2

This will hide all the document content except the text which is within the quotation marks after =>, e.g.

'group_id' => 'oră sferă',
'observe_user_id' => 'CEE carbonat nave',

This will also handle escaped quotation marks correctly, as well as different quotation marks which can be used in PHP associative arrays.

Once the content is hidden, you can import the Word document into any CAT tool that supports hidden formatting (Studio, memoQ, Wordfast Pro, Déjà Vu X, Memsource, SmartCAT). Once the document is translated, open it in Word and use the Unhide command.

Best regards,
Stanislav Okhvat
TransTools – Useful tools for every translator
Collapse


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Can any CAT handle PHP files?

Advanced search







Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »
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 »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search