@@ -111,16 +111,20 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
111111 continue ;
112112 }
113113
114- if (isset ($ translation ->target ) && 'needs-translation ' === (string ) $ translation ->target ->attributes ()['state ' ]) {
114+ $ source = (string ) (isset ($ attributes ['resname ' ]) && $ attributes ['resname ' ] ? $ attributes ['resname ' ] : $ translation ->source );
115+
116+ if (isset ($ translation ->target )
117+ && 'needs-translation ' === (string ) $ translation ->target ->attributes ()['state ' ]
118+ && \in_array ((string ) $ translation ->target , [$ source , (string ) $ translation ->source ], true )
119+ ) {
115120 continue ;
116121 }
117122
118- $ source = isset ($ attributes ['resname ' ]) && $ attributes ['resname ' ] ? $ attributes ['resname ' ] : $ translation ->source ;
119123 // If the xlf file has another encoding specified, try to convert it because
120124 // simple_xml will always return utf-8 encoded values
121125 $ target = $ this ->utf8ToCharset ((string ) ($ translation ->target ?? $ translation ->source ), $ encoding );
122126
123- $ catalogue ->set (( string ) $ source , $ target , $ domain );
127+ $ catalogue ->set ($ source , $ target , $ domain );
124128
125129 $ metadata = [
126130 'source ' => (string ) $ translation ->source ,
@@ -143,7 +147,7 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
143147 $ metadata ['id ' ] = (string ) $ attributes ['id ' ];
144148 }
145149
146- $ catalogue ->setMetadata (( string ) $ source , $ metadata , $ domain );
150+ $ catalogue ->setMetadata ($ source , $ metadata , $ domain );
147151 }
148152 }
149153 }
0 commit comments