10624ba5416045d73c22f658785a8d4b4640c07e
[lhc/web/wiklou.git] / serialized / serialize-localisation.php
1 <?php
2
3 $optionsWithArgs = array( 'o' );
4 require_once( dirname(__FILE__).'/../maintenance/commandLine.inc' );
5 require_once( dirname(__FILE__).'/serialize.php' );
6
7 $stderr = fopen( 'php://stderr', 'w' );
8 if ( !isset( $args[0] ) ) {
9 fwrite( $stderr, "No input file specified\n" );
10 exit( 1 );
11 }
12 $file = $args[0];
13 $code = str_replace( 'Messages', '', basename( $file ) );
14 $code = str_replace( '.php', '', $code );
15 $code = strtolower( str_replace( '_', '-', $code ) );
16
17 $localisation = Language::getLocalisationArray( $code, true );
18 if ( wfIsWindows() ) {
19 $localisation = unixLineEndings( $localisation );
20 }
21
22 if ( isset( $options['o'] ) ) {
23 $out = fopen( $options['o'], 'wb' );
24 if ( !$out ) {
25 fwrite( $stderr, "Unable to open file \"{$options['o']}\" for output\n" );
26 exit( 1 );
27 }
28 } else {
29 $out = fopen( 'php://stdout', 'wb' );
30 }
31
32 fwrite( $out, serialize( $localisation ) );
33
34 ?>