@@ -128,36 +128,37 @@ private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, $
128128 $ xml ->registerXPathNamespace ('xliff ' , 'urn:oasis:names:tc:xliff:document:2.0 ' );
129129
130130 foreach ($ xml ->xpath ('//xliff:unit ' ) as $ unit ) {
131- $ segment = $ unit ->segment ;
132- $ source = $ segment ->source ;
131+ foreach ( $ unit ->segment as $ segment ) {
132+ $ source = $ segment ->source ;
133133
134- // If the xlf file has another encoding specified, try to convert it because
135- // simple_xml will always return utf-8 encoded values
136- $ target = $ this ->utf8ToCharset ((string ) (isset ($ segment ->target ) ? $ segment ->target : $ source ), $ encoding );
134+ // If the xlf file has another encoding specified, try to convert it because
135+ // simple_xml will always return utf-8 encoded values
136+ $ target = $ this ->utf8ToCharset ((string ) (isset ($ segment ->target ) ? $ segment ->target : $ source ), $ encoding );
137137
138- $ catalogue ->set ((string ) $ source , $ target , $ domain );
138+ $ catalogue ->set ((string ) $ source , $ target , $ domain );
139139
140- $ metadata = array ();
141- if (isset ($ segment ->target ) && $ segment ->target ->attributes ()) {
142- $ metadata ['target-attributes ' ] = array ();
143- foreach ($ segment ->target ->attributes () as $ key => $ value ) {
144- $ metadata ['target-attributes ' ][$ key ] = (string ) $ value ;
140+ $ metadata = array ();
141+ if (isset ($ segment ->target ) && $ segment ->target ->attributes ()) {
142+ $ metadata ['target-attributes ' ] = array ();
143+ foreach ($ segment ->target ->attributes () as $ key => $ value ) {
144+ $ metadata ['target-attributes ' ][$ key ] = (string ) $ value ;
145+ }
145146 }
146- }
147147
148- if (isset ($ unit ->notes )) {
149- $ metadata ['notes ' ] = array ();
150- foreach ($ unit ->notes ->note as $ noteNode ) {
151- $ note = array ();
152- foreach ($ noteNode ->attributes () as $ key => $ value ) {
153- $ note [$ key ] = (string ) $ value ;
148+ if (isset ($ unit ->notes )) {
149+ $ metadata ['notes ' ] = array ();
150+ foreach ($ unit ->notes ->note as $ noteNode ) {
151+ $ note = array ();
152+ foreach ($ noteNode ->attributes () as $ key => $ value ) {
153+ $ note [$ key ] = (string ) $ value ;
154+ }
155+ $ note ['content ' ] = (string ) $ noteNode ;
156+ $ metadata ['notes ' ][] = $ note ;
154157 }
155- $ note ['content ' ] = (string ) $ noteNode ;
156- $ metadata ['notes ' ][] = $ note ;
157158 }
158- }
159159
160- $ catalogue ->setMetadata ((string ) $ source , $ metadata , $ domain );
160+ $ catalogue ->setMetadata ((string ) $ source , $ metadata , $ domain );
161+ }
161162 }
162163 }
163164
0 commit comments