22 $filename = basename(
$path );
23 return strpos( $filename,
'*' ) !==
false;
36 $pattern = $repos[$info[
'repo']];
37 unset( $info[
'repo'], $info[
'orig'] );
42 foreach ( array_keys( $info )
as $key ) {
43 $keys[] =
'%' . strtoupper( $key ) .
'%';
46 $values = array_values( $info );
47 return str_replace(
$keys, $values, $pattern );
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 ) {
76 $c = array_sum( array_map(
'count', $parsed ) );
78 # echo "$filename with " . get_class( $reader ) . " and $c\n";
94 foreach ( $remote
as $key =>
$value ) {
95 if ( isset( $blacklist[$key] ) ) {
99 if ( !isset( $origin[$key] ) ||
$value !== $origin[$key] ) {
114 $fetcher = $factory->getFetcher(
$path );
116 if ( $this->isDirectory(
$path ) ) {
117 $files = $fetcher->fetchDirectory(
$path );
119 $files = [
$path => $fetcher->fetchFile(
$path ) ];
123 return array_filter( $files );
129 FetcherFactory $fetcherFactory,
133 $components = $finder->getComponents();
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;