[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/scripts/ -> import-originals.php (source)

   1  <?php
   2  require_once dirname( dirname( __FILE__ ) ) . '/gp-load.php';
   3  
   4  class GP_Script_Import_Originals extends GP_CLI {
   5      
   6      var $short_options = 'p:f:o:';
   7      
   8      var $usage = "-p <project-path> -f <file> [-o <format>]";
   9      
  10  	function run() {
  11          if ( !isset( $this->options['p'] ) ) {
  12              $this->usage();
  13          }
  14          $project = GP::$project->by_path( $this->options['p'] );
  15          if ( !$project ) $this->error( __('Project not found!') );
  16  
  17          $format = gp_array_get( GP::$formats, isset( $this->options['o'] )? $this->options['o'] : 'po', null );
  18          if ( !$format ) $this->error( __('No such format.') );;
  19  
  20          $translations = $format->read_originals_from_file( $this->options['f'], $project );
  21          if ( !$translations ) {
  22              $this->error( __("Couldn't load translations from file!") );
  23          }
  24  
  25          list( $originals_added, $originals_existing ) = GP::$original->import_for_project( $project, $translations );
  26          echo sprintf( __("%s new strings were added, %s existing were updated."), $originals_added, $originals_existing )."\n";
  27      }
  28  }
  29  
  30  $gp_script_import_originals = new GP_Script_Import_Originals;
  31  $gp_script_import_originals->run();


Generated: Thu May 24 03:59:35 2012 Hosted by follow the white rabbit.