serialize-localisation.php 903 B

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