[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 $IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== '' 4 ? getenv( 'MW_INSTALL_PATH' ) 5 : realpath( dirname( __FILE__ ) . "/../../" ); 6 // Can use __DIR__ once we drop support for MW 1.19 7 8 require "$IP/maintenance/Maintenance.php"; 9 10 class LU extends Maintenance { 11 public function __construct() { 12 parent::__construct(); 13 $this->mDescription = 'Fetches translation updates to MediaWiki and extensions.'; 14 $this->addOption( 15 'repoid', 16 'Fetch translations from repositories identified by this', 17 false, /*required*/ 18 true /*has arg*/ 19 ); 20 } 21 22 public function execute() { 23 // Prevent the script from timing out 24 set_time_limit( 0 ); 25 ini_set( "max_execution_time", 0 ); 26 ini_set( 'memory_limit', -1 ); 27 28 global $wgExtensionMessagesFiles, $wgMessagesDirs, $IP; 29 global $wgLocalisationUpdateRepositories; 30 global $wgLocalisationUpdateRepository; 31 32 $dir = LocalisationUpdate::getDirectory(); 33 if ( !$dir ) { 34 $this->error( "No cache directory configured", true ); 35 return; 36 } 37 38 $finder = new LU_Finder( $wgExtensionMessagesFiles, $wgMessagesDirs, $IP ); 39 $readerFactory = new LU_ReaderFactory(); 40 $fetcherFactory = new LU_FetcherFactory(); 41 42 $repoid = $this->getOption( 'repoid', $wgLocalisationUpdateRepository ); 43 if ( !isset( $wgLocalisationUpdateRepositories[$repoid] ) ) { 44 $known = implode( ', ', array_keys( $wgLocalisationUpdateRepositories ) ); 45 $this->error( "Unknown repoid $repoid; known: $known", true ); 46 return; 47 } 48 $repos = $wgLocalisationUpdateRepositories[$repoid]; 49 50 // Do it ;) 51 $updater = new LU_Updater(); 52 $updatedMessages = $updater->execute( 53 $finder, 54 $readerFactory, 55 $fetcherFactory, 56 $repos 57 ); 58 59 // Store it ;) 60 $count = array_sum( array_map( 'count', $updatedMessages ) ); 61 if ( !$count ) { 62 $this->output( "Found no new translations\n" ); 63 return; 64 } 65 66 foreach ( $updatedMessages as $language => $messages ) { 67 $filename = "$dir/" . LocalisationUpdate::getFilename( $language ); 68 file_put_contents( $filename, FormatJson::encode( $messages, true ) ); 69 } 70 $this->output( "Saved $count new translations\n" ); 71 } 72 } 73 74 $maintClass = 'LU'; 75 require_once RUN_MAINTENANCE_IF_MAIN;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |