60 foreach ( $files as $filename => $contents ) {
61 $reader = $readerFactory->
getReader( $filename );
63 $parsed = $reader->parse( $contents );
64 }
catch ( \Exception $e ) {
65 trigger_error( __METHOD__ .
": Unable to parse messages from $filename", E_USER_WARNING );
69 foreach ( $parsed as $code => $langMessages ) {
70 if ( !isset( $messages[$code] ) ) {
71 $messages[$code] = [];
73 $messages[$code] = array_merge( $messages[$code], $langMessages );
76 $c = array_sum( array_map(
'count', $parsed ) );
78 # echo "$filename with " . get_class( $reader ) . " and $c\n";
135 $updatedMessages = [];
137 foreach ( $components as $key => $info ) {
138 $logger->logInfo(
"Updating component $key" );
140 $originFiles = $this->fetchFiles( $fetcherFactory, $info[
'orig'] );
141 $remotePath = $this->expandRemotePath( $info, $repos );
143 $remoteFiles = $this->fetchFiles( $fetcherFactory, $remotePath );
144 }
catch ( \Exception $e ) {
145 $logger->logError( __METHOD__ .
": Unable to fetch messages from $remotePath" );
149 if ( $remoteFiles === [] ) {
154 $originMessages = $this->readMessages( $readerFactory, $originFiles );
155 $remoteMessages = $this->readMessages( $readerFactory, $remoteFiles );
157 if ( !isset( $remoteMessages[
'en'] ) ) {
165 $forbiddenKeys = $this->findChangedTranslations(
166 $originMessages[
'en'],
167 $remoteMessages[
'en']
171 unset( $originMessages[
'en'], $remoteMessages[
'en'] );
174 foreach ( $remoteMessages as $language => $remoteTranslations ) {
176 $originTranslations = [];
177 if ( isset( $originMessages[$language] ) ) {
178 $originTranslations = $originMessages[$language];
181 $updatedTranslations = $this->findChangedTranslations(
188 if ( $updatedTranslations === [] ) {
192 if ( !isset( $updatedMessages[$language] ) ) {
193 $updatedMessages[$language] = [];
198 $updatedMessages[$language] += $updatedTranslations;
202 return $updatedMessages;