2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
|
|
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2008-10-30 17:30:26 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.console.libs
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5669
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Shell for I18N management.
|
|
|
|
*
|
2008-10-30 17:30:26 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.console.libs
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class I18nShell extends Shell {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Contains database source to use
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $dataSource = 'default';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Contains tasks to load and instantiate
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $tasks = array('DbConfig', 'Extract');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Override startup of the Shell
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function startup() {
|
2008-06-03 05:11:04 +00:00
|
|
|
$this->_welcome();
|
2008-05-30 11:40:08 +00:00
|
|
|
if (isset($this->params['datasource'])) {
|
|
|
|
$this->dataSource = $this->params['datasource'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->command && !in_array($this->command, array('help'))) {
|
|
|
|
if (!config('database')) {
|
|
|
|
$this->out(__('Your database configuration was not found. Take a moment to create one.', true), true);
|
|
|
|
return $this->DbConfig->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Override main() for help message hook
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function main() {
|
|
|
|
$this->out(__('I18n Shell', true));
|
|
|
|
$this->hr();
|
|
|
|
$this->out(__('[E]xtract POT file from sources', true));
|
|
|
|
$this->out(__('[I]nitialize i18n database table', true));
|
|
|
|
$this->out(__('[H]elp', true));
|
|
|
|
$this->out(__('[Q]uit', true));
|
|
|
|
|
2009-08-10 23:47:41 +00:00
|
|
|
$choice = strtolower($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
|
2008-10-23 00:10:44 +00:00
|
|
|
switch ($choice) {
|
2009-08-10 23:47:41 +00:00
|
|
|
case 'e':
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->Extract->execute();
|
|
|
|
break;
|
2009-08-10 23:47:41 +00:00
|
|
|
case 'i':
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->initdb();
|
|
|
|
break;
|
2009-08-10 23:47:41 +00:00
|
|
|
case 'h':
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->help();
|
|
|
|
break;
|
2009-08-10 23:47:41 +00:00
|
|
|
case 'q':
|
2008-05-30 11:40:08 +00:00
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
|
|
|
|
}
|
|
|
|
$this->hr();
|
|
|
|
$this->main();
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Initialize I18N database.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function initdb() {
|
2009-11-16 14:12:41 +00:00
|
|
|
$this->Dispatch->args = array('schema', 'create', 'i18n');
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->Dispatch->dispatch();
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Show help screen.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function help() {
|
|
|
|
$this->hr();
|
|
|
|
$this->out(__('I18n Shell:', true));
|
|
|
|
$this->hr();
|
|
|
|
$this->out(__('I18n Shell initializes i18n database table for your application', true));
|
|
|
|
$this->out(__('and generates .pot file(s) with translations.', true));
|
|
|
|
$this->hr();
|
|
|
|
$this->out(__('usage:', true));
|
|
|
|
$this->out(' cake i18n help');
|
|
|
|
$this->out(' cake i18n initdb [-datasource custom]');
|
2009-09-26 21:08:37 +00:00
|
|
|
$this->out();
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->hr();
|
|
|
|
|
|
|
|
$this->Extract->help();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|