diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /extensions/LocalisationUpdate/finder | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'extensions/LocalisationUpdate/finder')
-rw-r--r-- | extensions/LocalisationUpdate/finder/Finder.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/extensions/LocalisationUpdate/finder/Finder.php b/extensions/LocalisationUpdate/finder/Finder.php new file mode 100644 index 00000000..5c598730 --- /dev/null +++ b/extensions/LocalisationUpdate/finder/Finder.php @@ -0,0 +1,78 @@ +<?php +/** + * @file + * @author Niklas Laxström + * @license GPL-2.0+ + */ + +/** + * Interface for classes which provide list of components, which should be + * included for l10n updates. + */ +class LU_Finder { + /** + * @param array $php See $wgExtensionMessagesFiles + * @param array $json See $wgMessagesDirs + * @param string $core Absolute path to MediaWiki core + */ + public function __construct( $php, $json, $core ) { + $this->php = $php; + $this->json = $json; + $this->core = $core; + } + + /** + * @return array + */ + public function getComponents() { + $components = array(); + + // For older versions of Mediawiki, pull json updates even though its still using php + if ( !isset( $this->json['core'] ) ) { + $components['core'] = array( + 'repo' => 'mediawiki', + 'orig' => "file://{$this->core}/languages/messages/Messages*.php", + 'path' => 'languages/messages/i18n/*.json', + ); + } + + foreach ( $this->json as $key => $value ) { + // Json should take priority if both exist + unset( $this->php[$key] ); + + foreach ( (array)$value as $subkey => $subvalue ) { + // This ignores magic, alias etc. non message files + $matches = array(); + $ok = preg_match( '~/extensions/(?P<name>[^/]+)/(?P<path>.*)$~', $subvalue, $matches ); + if ( !$ok ) { + continue; + } + + $components["$key-$subkey"] = array( + 'repo' => 'extension', + 'name' => $matches['name'], + 'orig' => "file://$subvalue/*.json", + 'path' => "{$matches['path']}/*.json", + ); + } + } + + foreach ( $this->php as $key => $value ) { + // This currently skips core i18n files like resources/oojs-ui/i18n + $matches = array(); + $ok = preg_match( '~/extensions/(?P<name>[^/]+)/(?P<path>.*\.i18n\.php)$~', $value, $matches ); + if ( !$ok ) { + continue; + } + + $components[$key] = array( + 'repo' => 'extension', + 'name' => $matches['name'], + 'orig' => "file://$value", + 'path' => $matches['path'], + ); + } + + return $components; + } +} |