i18n.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: i18n.php 7847 2008-11-08 02:54:07Z renan.saddam $ */
00003 /**
00004  * Short description for file.
00005  *
00006  * Long description for file
00007  *
00008  * PHP versions 4 and 5
00009  *
00010  * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
00011  * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00012  *
00013  * Licensed under The MIT License
00014  * Redistributions of files must retain the above copyright notice.
00015  *
00016  * @filesource
00017  * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00018  * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00019  * @package       cake
00020  * @subpackage    cake.cake.console.libs
00021  * @since         CakePHP(tm) v 1.2.0.5669
00022  * @version       $Revision: 7847 $
00023  * @modifiedby    $LastChangedBy: renan.saddam $
00024  * @lastmodified  $Date: 2008-11-07 21:54:07 -0500 (Fri, 07 Nov 2008) $
00025  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
00026  */
00027 /**
00028  * Shell for I18N management.
00029  *
00030  * @package       cake
00031  * @subpackage    cake.cake.console.libs
00032  */
00033 class I18nShell extends Shell {
00034 /**
00035  * Contains database source to use
00036  *
00037  * @var string
00038  * @access public
00039  */
00040     var $dataSource = 'default';
00041 /**
00042  * Contains tasks to load and instantiate
00043  *
00044  * @var array
00045  * @access public
00046  */
00047     var $tasks = array('DbConfig', 'Extract');
00048 /**
00049  * Override startup of the Shell
00050  *
00051  * @access public
00052  */
00053     function startup() {
00054         $this->_welcome();
00055         if (isset($this->params['datasource'])) {
00056             $this->dataSource = $this->params['datasource'];
00057         }
00058 
00059         if ($this->command && !in_array($this->command, array('help'))) {
00060             if (!config('database')) {
00061                 $this->out(__('Your database configuration was not found. Take a moment to create one.', true), true);
00062                 return $this->DbConfig->execute();
00063             }
00064         }
00065     }
00066 /**
00067  * Override main() for help message hook
00068  *
00069  * @access public
00070  */
00071     function main() {
00072         $this->out(__('I18n Shell', true));
00073         $this->hr();
00074         $this->out(__('[E]xtract POT file from sources', true));
00075         $this->out(__('[I]nitialize i18n database table', true));
00076         $this->out(__('[H]elp', true));
00077         $this->out(__('[Q]uit', true));
00078 
00079         $choice = strtoupper($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
00080         switch ($choice) {
00081             case 'E':
00082                 $this->Extract->execute();
00083             break;
00084             case 'I':
00085                 $this->initdb();
00086             break;
00087             case 'H':
00088                 $this->help();
00089             break;
00090             case 'Q':
00091                 exit(0);
00092             break;
00093             default:
00094                 $this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
00095         }
00096         $this->hr();
00097         $this->main();
00098     }
00099 /**
00100  * Initialize I18N database.
00101  *
00102  * @access public
00103  */
00104     function initdb() {
00105         $this->Dispatch->args = array('schema', 'run', 'create', 'i18n');
00106         $this->Dispatch->dispatch();
00107     }
00108 /**
00109  * Show help screen.
00110  *
00111  * @access public
00112  */
00113     function help() {
00114         $this->hr();
00115         $this->out(__('I18n Shell:', true));
00116         $this->hr();
00117         $this->out(__('I18n Shell initializes i18n database table for your application', true));
00118         $this->out(__('and generates .pot file(s) with translations.', true));
00119         $this->hr();
00120         $this->out(__('usage:', true));
00121         $this->out('   cake i18n help');
00122         $this->out('   cake i18n initdb [-datasource custom]');
00123         $this->out('');
00124         $this->hr();
00125 
00126         $this->Extract->help();
00127     }
00128 }
00129 ?>

Generated on Sun Nov 22 00:30:51 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7