Source for file I18n.php

Documentation is available at I18n.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  I18n.php
  5.  *
  6.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: f5437bbabb835faae7e74e51a1e9cc237f98c60c $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Handle_I18n
  13. /**
  14.  *  i18n handler
  15.  *
  16.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  generate message catalog.
  23.      *
  24.      *  @access public
  25.      */
  26.     function perform()
  27.     {
  28.         $r $this->_getopt(
  29.                   array('basedir=',
  30.                         'locale=',
  31.                         'gettext',
  32.                   )
  33.              );
  34.         if (Ethna::isError($r)) {
  35.             return $r;
  36.         }
  37.         list($opt_list$arg_list$r;
  38.  
  39.         // basedir
  40.         if (isset($opt_list['basedir'])) {
  41.             $basedir realpath(end($opt_list['basedir']));
  42.         else {
  43.             $basedir getcwd();
  44.         }
  45.  
  46.         // locale
  47.         if (isset($opt_list['locale'])) {
  48.             $locale end($opt_list['locale']);
  49.             if (!preg_match('/^[A-Za-z_]+$/'$locale)) {
  50.                 return Ethna::raiseError("You specified locale, but invalid : $locale"'usage');
  51.             }
  52.         else {
  53.             $locale 'ja_JP';  //  default locale. 
  54.         }
  55.  
  56.         //  use gettext ?
  57.         $use_gettext (isset($opt_list['gettext'])) true false;
  58.  
  59.         //  generate message catalog.
  60.         $ret Ethna_Generator::generate('I18n'$basedir$locale$use_gettext$arg_list);
  61.         if (Ethna::isError($ret)) {
  62.             printf("error occurred while generating skelton. please see also following error message(s)\n\n");
  63.             return $ret;
  64.         }
  65.  
  66.         return $ret;
  67.     }
  68.  
  69.     /**
  70.      *  get handler's description
  71.      *
  72.      *  @access public
  73.      */
  74.     function getDescription()
  75.     {
  76.         return <<<EOS
  77. generate message catalog of project:
  78.     {$this->id} [-b|--basedir=dir] [-l|--locale=locale] [-g|--gettext] [extdir1] [extdir2] ...
  79.  
  80. EOS;
  81.     }
  82.  
  83.     /**
  84.      *  @access public
  85.      */
  86.     function getUsage()
  87.     {
  88.         return <<<EOS
  89. ethna {$this->id} [-b|--basedir=dir] [-l|--locale=locale] [-g|--gettext] [extdir1] [extdir2] ...
  90.  
  91. EOS;
  92.     }
  93. }
  94. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:16 +0900 by phpDocumentor 1.4.3