[RCD] Script to convert Language arrays to OASIS Standard XML Language Interchange File Format

Thomas Meyer T.Meyer at cc-carconsult.de
Fri Mar 19 12:38:14 CET 2010

Hi Devs,

I recently wrote a little script that I would like to share with you.

It automates the conversion of RoundCube language arrays to OASIS XLIFFs, which is an international standard for translations.
These files may then be edited using Translation Memory Tools like Omega-T or Sun's XLIFF-Editor. These provide a graphical interface, multi-translator support, spell-checking aso. Long story short: it makes translations a lot easier.

Accessing a XLIFF file from PHP is easy. Check this example:

    function getArray($locale, $fileId)
        $file = simplexml_load_file("languages/" . $locale . "/" . $fileId . ".xlf");
        if (!($file instanceof SimpleXMLElement)) {
            throw new InvalidArgumentException('File-id not valid: ' . $file);
        $translations = array();
        foreach ($file->xpath('//trans-unit') as $node)
            $attributes =  $node->attributes();
            $translations[(string) $attributes['id']] = (string) $node->target;
        return $translations;

You will find the script and an example XLIFF as an attachment to this message.
Check it out.

Thomas Meyer

 --- 8< --- detachments --- 8< ---
 The following attachments have been detached and are available for viewing.
 Only click these links if you trust the sender, as well as this message.
 --- 8< --- detachments --- 8< ---

-------------- next part --------------
List info: http://lists.roundcube.net/dev/

More information about the Dev mailing list