[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/i18n/cli/ -> I18nCliCmd.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/i18n/common.inc.php');
  10  lmb_require('limb/i18n/src/translation/lmbDictionaryUpdater.class.php');
  11  lmb_require('limb/i18n/src/translation/lmbQtDictionaryBackend.class.php');
  12  
  13  /**

  14   * class I18nCliCmd.

  15   *

  16   * @package i18n

  17   * @version $Id$

  18   */
  19  class I18nCliCmd extends lmbCliBaseCmd
  20  {
  21    function execute($argv)
  22    {
  23      $this->help($argv);
  24    }
  25  
  26    function updateTranslations($argv)
  27    {
  28      $input = new lmbCliInput('t|test');
  29      $input->read($argv, false);
  30  
  31      $dry_run = $input->isOptionPresent('t');
  32  
  33      $input_dir = realpath($input->getArgument(0, '.'));
  34  
  35      if(!$input_dir)
  36        $this->_error('Input directory is not valid');
  37  
  38      $output_dir = realpath($input->getArgument(1, $input_dir . '/i18n/translations'));
  39  
  40      if(!$output_dir)
  41        $this->_error('Output directory is not valid');
  42  
  43      $qt = new lmbQtDictionaryBackend();
  44      $qt->setSearchPath($output_dir);
  45  
  46      $util = new lmbDictionaryUpdater($qt, $this->output);
  47  
  48      if($dry_run)
  49        $util->dryrun($input_dir);
  50      else
  51        $util->updateTranslations($input_dir);
  52  
  53      return 0;
  54    }
  55  
  56    function ut($argv)
  57    {
  58      return $this->updateTranslations($argv);
  59    }
  60  
  61    function help($argv)
  62    {
  63      $txt = <<<EOD
  64  Usage:
  65    i18n update-tranlsations(ut) [-t|--test] [<src_dir>] [<dictionary_dir>]
  66  
  67    Updates all translation dictionaries with new untranslated entries(currently only Qt
  68    dictionaries supported). Parses PHP and WACT templates sources in <src_dir>(current dir .
  69    by default) and updates dictionaries in <dictionary_dir>(./i18n/translations by default)
  70  
  71  Options:
  72    -t, --test    performs 'dry-run' without updating dictionaries, useful for previewing updates
  73  
  74  EOD;
  75  
  76      echo $txt;
  77    }
  78  }
  79  
  80  ?>


Generated: Sat Aug 30 04:38:32 2008 Cross-referenced by PHPXref 0.7