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,
132 $components = $finder->getComponents();
134 $updatedMessages = [];
136 foreach ( $components
as $key => $info ) {
137 $originFiles = $this->fetchFiles( $fetcherFactory, $info[
'orig'] );
138 $remoteFiles = $this->fetchFiles( $fetcherFactory, $this->expandRemotePath( $info, $repos ) );
140 if ( $remoteFiles === [] ) {
145 $originMessages = $this->readMessages( $readerFactory, $originFiles );
146 $remoteMessages = $this->readMessages( $readerFactory, $remoteFiles );
148 if ( !isset( $remoteMessages[
'en'] ) ) {
156 $forbiddenKeys = $this->findChangedTranslations(
157 $originMessages[
'en'],
158 $remoteMessages[
'en']
162 unset( $originMessages[
'en'], $remoteMessages[
'en'] );
165 foreach ( $remoteMessages
as $language => $remoteTranslations ) {
167 $originTranslations = [];
168 if ( isset( $originMessages[$language] ) ) {
169 $originTranslations = $originMessages[$language];
172 $updatedTranslations = $this->findChangedTranslations(
179 if ( $updatedTranslations === [] ) {
183 if ( !isset( $updatedMessages[$language] ) ) {
184 $updatedMessages[$language] = [];
189 $updatedMessages[$language] += $updatedTranslations;
193 return $updatedMessages;