1

That's my first question here, normally I provide answers ;-)

Well, I'm looking for a script to extract some specific strings set into system.xml, layout xml files or similar they are used by Magento to translate them. Example: labels, menu item or else.

I have a script to extract them from php and phtml files thanks to gettext and convert them to a Portable Object file, then, I use the PO file to translate the strings thanks to OmegaT Software and finally I have also a PHP CLI script to convert the translated files from PO to CSV files.

Magento translates these xml files by using the module and the element information provided thanks to the attribute "translate='element_to_translate'" and "module='mymodule'" placed in an element (block or action for example) internally via an helper.

Here an example of xml code that I want to extract to allow me to translate it. Here I would like to translate the value of the element "label" thanks to the module "sales", as you see below the attributes in the XML code could be helpful to extract this information:

<customer_account>
        <reference name="customer_account_navigation" >
            <action method="addLink" translate="label" module="sales"><name>billing_agreements</name><path>sales/billing_agreement/</path><label>Billing Agreements</label></action>

or an other example:

<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
            </block>
        </reference>
</customer_account>

So if someone has a script which allows to extract them it will be great. Honestly I didn't have the time to create such a script because I used already lots of time to create the whole process for the translation which stay complicated. But if someone did already the job, it will be great to share it here. However if people search the script to do the conversion from CSV to PO and reverse, I can help although it is fundable on the web. I just made some cosmetic changes compared to the original version.

Thanks for your feedbacks.

Sylvain Rayé
  • 2,456
  • 16
  • 23

4 Answers4

2

I have made a module for extracting strings to translate directly to csv files, in Magento format. If I recall correctly it handles the config and system xml's, not sure about the layout though.
Give it a try and feel free to improve it :)

https://bitbucket.org/OSdave/languagecsv

OSdave
  • 8,538
  • 7
  • 45
  • 60
  • Hi, it is very close from what I'm looking for. It does the translation for system.xml file. I need also for layout xml files but the basic are there, I will improve it and share it into your repo. I have already done some cosmetic improvements. Thanks. I will set this reply as answer when I'm done. – Sylvain Rayé Jan 04 '13 at 16:05
  • I'm glad you find it useful. Let me know if I can help with the module – OSdave Jan 04 '13 at 19:28
  • In fact, I helped ;-) See your git repo. I changed it to make working with all xml files included into the module folder and for all layout XML files used by the module thanks to a parse of the config.xml file. Your module helped me to make a module responding to my needs. Thanks – Sylvain Rayé Jan 07 '13 at 18:51
2

Check out Bryan Schnabel's XML - XLIFF round-trip tool: http://sourceforge.net/projects/xliffroundtrip/

xliffRoundTrip automates a roundtrip between any XML file and XLIFF. It consists of 2 XSL files + Java source. The 1st transforms XML to XLIFF. The 2nd transforms that XLIFF back to the original XML, i.e., after a language translation on the XLIFF file.

Bryan is a long-time member of the OASIS XLIFF tech comm.

Doug Domeny
  • 4,410
  • 2
  • 33
  • 49
  • Thank you for your feedback. It is an interesting tool, and yes I can use the XLIFF file into OmegaT. The solution provided by @OSDave seems to fit more to Magento. It definitely helps to translate Magento modules in an easy way. Your solution is also a good alternative. – Sylvain Rayé Jan 04 '13 at 16:24
0

There are professional translation tools out there, like for example SDL Trados that do such things. With trados you would not convert it into csv, but into xliff, which is a standard format for translation files.

Remy
  • 12,555
  • 14
  • 64
  • 104
  • Hi and thank you for your feedback. I'm not looking for a software to translate the strings. I search a way to extract the strings from a XML file formatted by Magento like in my example to use my favorite translation software. I don't think that SDL Trados can do that. – Sylvain Rayé Jan 04 '13 at 14:05
  • What is your favorite Translation Software? Trados can export XLIFF files. – Remy Jan 04 '13 at 17:04
  • It is OmegaT but I understand what you mean and you're right but it is not exactly what I'm looking for. I mean having an additional format and then merging into a PO file (I have others strings from my code to merge with the XML strings) and then converting in CSV file. It makes more work & chance to have problems with some special strings. There is a free solution provided by Doug which is a non commercial software to do the same purpose as Trados. And as I said to Doug I prefer the solution of @OSDave because I use Magento and his module extracts almost all what I need into a CSV file. – Sylvain Rayé Jan 04 '13 at 17:27
0

SDL Trados Studio allows you create custom rules to process xml files. SDL calls them 'file types'. See a basic introduction here: http://producthelp.sdl.com/kb/Articles/5274.html

File types allow you to specify which elements and attributes are (un)translatable.

SDL Trados Studio does not allow you evaluate the 'translatability' of an element on the basis of an attribute in parent element.

In other words:

  • if you always have to translate the label element: SDL Trados Studio can handle it if you create a file type. The translate attribute of the action element is useless.
  • if you don't always have to translate the label element, but want to evaluate it based on the translate attribute, you really need a script to preprocess (and postprocess afterwards). But since you're building your own xml file, I suppose you could build it so translatable content is in an identifiable element.

If you're looking for a free solution, check out Memsource. They allow exactly the same principle, but I'm less familiar with the exact procedure.