My script to convert it looks as follows:<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-ope +n.org/committees/xliff/documents/xliff.dtd" > <xliff version="1.0"> <file datatype="plaintext" original="game/stringtable/Example.stt" so +urce-language="en" target-language="de" xml:space="default"> <header/> <body> <trans-unit approved="yes" id="Example_monsternpc_greeting" reforma +t="yes" translate="yes" xml:space="default"> <source>'I am a monster NPC.'</source><target state="translated" x +ml:lang="de">'Ich bin ein Monster-NSC.'</target> <prop-group><prop prop-type="entryid">1173668791078</prop></prop-gr +oup><alt-trans match-quality="100" origin="5k" xml:space="default"><s +ource xml:lang="en">'I am a monster NPC.'</source><target xml:lang="d +e">'Ich bin ein Monster-NSC.'</target><prop-group><prop prop-type="en +tryid">1173668807656</prop></prop-group></alt-trans></trans-unit> <trans-unit approved="yes" id="Example_monsternpc_pc_transform" ref +ormat="yes" translate="yes" xml:space="default"> <source>'Turn into a monster.'</source><target xml:lang="de">'In e +in Monster verwandeln.'</target> <prop-group><prop prop-type="entryid">1173668791093</prop></prop-gr +oup><alt-trans match-quality="100" origin="5k" xml:space="default"><s +ource xml:lang="en">'Turn into a monster.'</source><target xml:lang=" +de">'In ein Monster verwandeln.'</target><prop-group><prop prop-type= +"entryid">1173668807671</prop></prop-group></alt-trans></trans-unit> <trans-unit approved="yes" id="Example_private_testMe2" reformat="y +es" translate="yes" xml:space="default"> <source>and again</source><target xml:lang="de">und noch einer</ta +rget> <prop-group><prop prop-type="entryid">1173668791109</prop></prop-gr +oup><alt-trans match-quality="100" origin="5k" xml:space="default"><s +ource xml:lang="en">and again</source><target xml:lang="de">und noch +einer</target><prop-group><prop prop-type="entryid">1173668807687</pr +op></prop-group></alt-trans></trans-unit> </body> </file> <file datatype="plaintext" original="game/stringtable/training_skelet +on.stt" source-language="en" target-language="de" xml:space="default" +> <header/> <body> <trans-unit approved="yes" id="training_skeleton_ID_KillMe" reforma +t="yes" translate="yes" xml:space="default"> <source>You should get to know Sigmund before leaving to explore S +tormreach.</source><target xml:lang="de">Ihr solltet Sigmund kennenle +rnen, bevor Ihr Euch aufmacht, um Stormreach zu erkunden.</target> <prop-group><prop prop-type="entryid">1173668791328</prop></prop-gr +oup><alt-trans match-quality="100" origin="5k" xml:space="default"><s +ource xml:lang="en">You should get to know Sigmund before leaving to +explore Stormreach.</source><target xml:lang="de">Ihr solltet Sigmund + kennenlernen, bevor Ihr Euch aufmacht, um Stormreach zu erkunden.</t +arget><prop-group><prop prop-type="entryid">1173668807906</prop></pro +p-group></alt-trans></trans-unit> </body> </file> </xliff>
And the output is this:#!/bin/perl use strict; use warnings; use XML::Simple; my $config = XMLin("meep.xlf", ForceArray => 1); open(EXTR, ">meep.csv") or die $!; foreach my $i ( 0 .. $#{ $config->{file} } ) { my $file = $config->{file}->[$i]->{original}; $file =~ s/game\/stringtable\///i; for my $entry ( keys %{ $config->{file}->[$i]->{body}->[0]->{'tran +s-unit'} } ) { my $source = $config->{file}->[$i]->{body}->[0]->{'trans-unit' +}->{$entry}->{source}->[0]; my $target = $config->{file}->[$i]->{body}->[0]->{'trans-unit' +}->{$entry}->{target}->[0]->{content}; print EXTR '"'.$file.'","'.$entry.'","'.$source.'","'.$target. +'"'."\n"; } } close EXTR;
The problem i have with this is: For some reason it has decided to change the order in which the elements are in the original file. (And it apprently does so randomly.) Is there a way to tell XMLIn something to the effect of: Just leave that stuff in the order you found it!"Example.stt","Example_monsternpc_greeting","'I am a monster NPC.'","' +Ich bin ein Monster-NSC.'" "Example.stt","Example_private_testMe2","and again","und noch einer" "Example.stt","Example_monsternpc_pc_transform","'Turn into a monster. +'","'In ein Monster verwandeln.'" "training_skeleton.stt","training_skeleton_ID_KillMe","You should get +to know Sigmund before leaving to explore Stormreach.","Ihr solltet S +igmund kennenlernen, bevor Ihr Euch aufmacht, um Stormreach zu erkund +en."
In reply to sort order of imported xml data? by Xenofur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |