@@ -128,36 +128,37 @@ private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, $
128
128
$ xml ->registerXPathNamespace ('xliff ' , 'urn:oasis:names:tc:xliff:document:2.0 ' );
129
129
130
130
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 ;
133
133
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 );
137
137
138
- $ catalogue ->set ((string ) $ source , $ target , $ domain );
138
+ $ catalogue ->set ((string ) $ source , $ target , $ domain );
139
139
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
+ }
145
146
}
146
- }
147
147
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 ;
154
157
}
155
- $ note ['content ' ] = (string ) $ noteNode ;
156
- $ metadata ['notes ' ][] = $ note ;
157
158
}
158
- }
159
159
160
- $ catalogue ->setMetadata ((string ) $ source , $ metadata , $ domain );
160
+ $ catalogue ->setMetadata ((string ) $ source , $ metadata , $ domain );
161
+ }
161
162
}
162
163
}
163
164
0 commit comments