Updating console to use i18n'ed strings.

This commit is contained in:
Renan Gonçalves 2011-04-25 21:17:59 +02:00
parent 3251faf8e9
commit abbe5aaea2
24 changed files with 153 additions and 166 deletions

View file

@ -71,10 +71,8 @@ class AclShell extends Shell {
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) { if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
$out = "--------------------------------------------------\n"; $out = "--------------------------------------------------\n";
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to') . "\n"; $out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
$out .= __d('cake_console', 'an ACL implementation other than DB. Please change') . "\n"; $out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
$out .= __d('cake_console', 'your core config to reflect your decision to use') . "\n";
$out .= __d('cake_console', 'DbAcl before attempting to use this script') . ".\n";
$out .= "--------------------------------------------------\n"; $out .= "--------------------------------------------------\n";
$out .= __d('cake_console', 'Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n"; $out .= __d('cake_console', 'Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n";
$out .= "--------------------------------------------------\n"; $out .= "--------------------------------------------------\n";
@ -150,7 +148,7 @@ class AclShell extends Shell {
$nodeId = $this->_getNodeId($class, $identifier); $nodeId = $this->_getNodeId($class, $identifier);
if (!$this->Acl->{$class}->delete($nodeId)) { if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists', $class) . ".\n"); $this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists.', $class) . "\n");
} }
$this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2); $this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2);
} }
@ -263,7 +261,7 @@ class AclShell extends Shell {
} }
/** /**
* Set an ARO to inhermit permission to an ACO. * Set an ARO to inherit permission to an ACO.
* *
*/ */
public function inherit() { public function inherit() {
@ -308,7 +306,7 @@ class AclShell extends Shell {
$this->error(__d('cake_console', '%s not found', $this->args[0]), __d('cake_console', 'No tree returned.')); $this->error(__d('cake_console', '%s not found', $this->args[0]), __d('cake_console', 'No tree returned.'));
} }
} }
$this->out($class . " tree:"); $this->out($class . ' tree:');
$this->hr(); $this->hr();
$stack = array(); $stack = array();
@ -357,7 +355,7 @@ class AclShell extends Shell {
'help' => __d('cake_console', 'Type of node to create.') 'help' => __d('cake_console', 'Type of node to create.')
); );
$parser->description('A console tool for managing the DbAcl') $parser->description(__d('cake_console', 'A console tool for managing the DbAcl'))
->addSubcommand('create', array( ->addSubcommand('create', array(
'help' => __d('cake_console', 'Create a new ACL node'), 'help' => __d('cake_console', 'Create a new ACL node'),
'parser' => array( 'parser' => array(
@ -407,8 +405,7 @@ class AclShell extends Shell {
'parser' => array( 'parser' => array(
'description' => array( 'description' => array(
__d('cake_console', "Returns the path to the ACL object specified by <node>."), __d('cake_console', "Returns the path to the ACL object specified by <node>."),
__d('cake_console', "This command is useful in determining the inhertiance of permissions"), __d('cake_console', "This command is useful in determining the inheritance of permissions for a certain object in the tree.")
__d('cake_console', "for a certain object in the tree.")
), ),
'arguments' => array( 'arguments' => array(
'type' => $type, 'type' => $type,
@ -422,9 +419,7 @@ class AclShell extends Shell {
'help' => __d('cake_console', 'Check the permissions between an ACO and ARO.'), 'help' => __d('cake_console', 'Check the permissions between an ACO and ARO.'),
'parser' => array( 'parser' => array(
'description' => array( 'description' => array(
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO "), __d('cake_console', 'Use this command to grant ACL permissions. Once executed, the ARO specified (and its children, if any) will have ALLOW access to the specified ACO action (and the ACO\'s children, if any).')
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
), ),
'arguments' => array( 'arguments' => array(
'aro' => array('help' => __d('cake_console', 'ARO to check.'), 'required' => true), 'aro' => array('help' => __d('cake_console', 'ARO to check.'), 'required' => true),
@ -436,9 +431,7 @@ class AclShell extends Shell {
'help' => __d('cake_console', 'Grant an ARO permissions to an ACO.'), 'help' => __d('cake_console', 'Grant an ARO permissions to an ACO.'),
'parser' => array( 'parser' => array(
'description' => array( 'description' => array(
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO"), __d('cake_console', 'Use this command to grant ACL permissions. Once executed, the ARO specified (and its children, if any) will have ALLOW access to the specified ACO action (and the ACO\'s children, if any).')
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
), ),
'arguments' => array( 'arguments' => array(
'aro' => array('help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true), 'aro' => array('help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true),
@ -450,9 +443,7 @@ class AclShell extends Shell {
'help' => __d('cake_console', 'Deny an ARO permissions to an ACO.'), 'help' => __d('cake_console', 'Deny an ARO permissions to an ACO.'),
'parser' => array( 'parser' => array(
'description' => array( 'description' => array(
__d('cake_console', "Use this command to deny ACL permissions. Once executed, the ARO"), __d('cake_console', 'Use this command to deny ACL permissions. Once executed, the ARO specified (and its children, if any) will have DENY access to the specified ACO action (and the ACO\'s children, if any).')
__d('cake_console', "specified (and its children, if any) will have DENY access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
), ),
'arguments' => array( 'arguments' => array(
'aro' => array('help' => __d('cake_console', 'ARO to deny.'), 'required' => true), 'aro' => array('help' => __d('cake_console', 'ARO to deny.'), 'required' => true),
@ -464,11 +455,10 @@ class AclShell extends Shell {
'help' => __d('cake_console', 'Inherit an ARO\'s parent permissions.'), 'help' => __d('cake_console', 'Inherit an ARO\'s parent permissions.'),
'parser' => array( 'parser' => array(
'description' => array( 'description' => array(
__d('cake_console', "Use this command to force a child ARO object to inherit its"), __d('cake_console', "Use this command to force a child ARO object to inherit its permissions settings from its parent.")
__d('cake_console', "permissions settings from its parent.")
), ),
'arguments' => array( 'arguments' => array(
'aro' => array('help' => __d('cake_console', 'ARO to have permisssions inherit.'), 'required' => true), 'aro' => array('help' => __d('cake_console', 'ARO to have permissions inherit.'), 'required' => true),
'aco' => array('help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true), 'aco' => array('help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true),
'action' => array('help' => __d('cake_console', 'Action to inherit'), 'default' => 'all') 'action' => array('help' => __d('cake_console', 'Action to inherit'), 'default' => 'all')
) )
@ -526,7 +516,7 @@ class AclShell extends Shell {
} }
/** /**
* Parse an identifier into Model.foriegnKey or an alias. * Parse an identifier into Model.foreignKey or an alias.
* Takes an identifier determines its type and returns the result as used by other methods. * Takes an identifier determines its type and returns the result as used by other methods.
* *
* @param string $identifier Identifier to parse * @param string $identifier Identifier to parse

View file

@ -36,7 +36,7 @@ class ApiShell extends Shell {
public $paths = array(); public $paths = array();
/** /**
* Override intialize of the Shell * Override initialize of the Shell
* *
*/ */
public function initialize() { public function initialize() {
@ -140,9 +140,9 @@ class ApiShell extends Shell {
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
$parser->addArgument('type', array( $parser->addArgument('type', array(
'help' => 'Either a full path or type of class (model, behavior, controller, component, view, helper)' 'help' => __d('cake_console', 'Either a full path or type of class (model, behavior, controller, component, view, helper)')
))->addArgument('className', array( ))->addArgument('className', array(
'help' => 'A CakePHP core class name (e.g: Component, HtmlHelper).' 'help' => __d('cake_console', 'A CakePHP core class name (e.g: Component, HtmlHelper).')
))->addOption('method', array( ))->addOption('method', array(
'short' => 'm', 'short' => 'm',
'help' => __d('cake_console', 'The specific method you want help on.') 'help' => __d('cake_console', 'The specific method you want help on.')
@ -181,7 +181,7 @@ class ApiShell extends Shell {
} elseif (isset($commands[strtolower($this->args[1])])) { } elseif (isset($commands[strtolower($this->args[1])])) {
$this->out($commands[strtolower($this->args[1])] . "\n\n"); $this->out($commands[strtolower($this->args[1])] . "\n\n");
} else { } else {
$this->out("Command '" . $this->args[1] . "' not found"); $this->out(__d('cake_console', 'Command %s not found', $this->args[1]));
} }
} }

View file

@ -79,16 +79,16 @@ class BakeShell extends Shell {
$this->args = null; $this->args = null;
return $this->DbConfig->execute(); return $this->DbConfig->execute();
} }
$this->out('Interactive Bake Shell'); $this->out(__d('cake_console', 'Interactive Bake Shell'));
$this->hr(); $this->hr();
$this->out('[D]atabase Configuration'); $this->out(__d('cake_console', '[D]atabase Configuration'));
$this->out('[M]odel'); $this->out(__d('cake_console', '[M]odel'));
$this->out('[V]iew'); $this->out(__d('cake_console', '[V]iew'));
$this->out('[C]ontroller'); $this->out(__d('cake_console', '[C]ontroller'));
$this->out('[P]roject'); $this->out(__d('cake_console', '[P]roject'));
$this->out('[F]ixture'); $this->out(__d('cake_console', '[F]ixture'));
$this->out('[T]est case'); $this->out(__d('cake_console', '[T]est case'));
$this->out('[Q]uit'); $this->out(__d('cake_console', '[Q]uit'));
$classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q'))); $classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q')));
switch ($classToBake) { switch ($classToBake) {
@ -199,12 +199,11 @@ class BakeShell extends Shell {
*/ */
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
return $parser->description( return $parser->description(__d('cake_console',
'The Bake script generates controllers, views and models for your application.' . 'The Bake script generates controllers, views and models for your application.'
'If run with no command line arguments, Bake guides the user through the class' . . ' If run with no command line arguments, Bake guides the user through the class creation process.' .
'creation process. You can customize the generation process by telling Bake' . . ' You can customize the generation process by telling Bake where different parts of your application are using command line arguments.'
'where different parts of your application are using command line arguments.' ))->addSubcommand('all', array(
)->addSubcommand('all', array(
'help' => __d('cake_console', 'Bake a complete MVC. optional <name> of a Model'), 'help' => __d('cake_console', 'Bake a complete MVC. optional <name> of a Model'),
))->addSubcommand('project', array( ))->addSubcommand('project', array(
'help' => __d('cake_console', 'Bake a new app folder in the path supplied or in current directory if no path is specified'), 'help' => __d('cake_console', 'Bake a new app folder in the path supplied or in current directory if no path is specified'),
@ -231,7 +230,7 @@ class BakeShell extends Shell {
'help' => __d('cake_console', 'Bake a unit test.'), 'help' => __d('cake_console', 'Bake a unit test.'),
'parser' => $this->Test->getOptionParser() 'parser' => $this->Test->getOptionParser()
))->addOption('connection', array( ))->addOption('connection', array(
'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'), 'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'),
'short' => 'c', 'short' => 'c',
'default' => 'default' 'default' => 'default'
)); ));

View file

@ -43,18 +43,17 @@ class CommandListShell extends Shell {
*/ */
public function main() { public function main() {
if (empty($this->params['xml'])) { if (empty($this->params['xml'])) {
$this->out("<info>Current Paths:</info>", 2); $this->out(__d('cake_console', "<info>Current Paths:</info>"), 2);
$this->out(" -app: ". APP_DIR); $this->out(" -app: ". APP_DIR);
$this->out(" -working: " . rtrim(APP_PATH, DS)); $this->out(" -working: " . rtrim(APP_PATH, DS));
$this->out(" -root: " . rtrim(ROOT, DS)); $this->out(" -root: " . rtrim(ROOT, DS));
$this->out(" -core: " . rtrim(CORE_PATH, DS)); $this->out(" -core: " . rtrim(CORE_PATH, DS));
$this->out(""); $this->out("");
$this->out("<info>Changing Paths:</info>", 2); $this->out(__d('cake_console', "<info>Changing Paths:</info>"), 2);
$this->out("Your working path should be the same as your application path"); $this->out(__d('cake_console', "Your working path should be the same as your application path to change your path use the '-app' param."));
$this->out("to change your path use the '-app' param."); $this->out(__d('cake_console', "Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp"), 2);
$this->out("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp", 2);
$this->out("<info>Available Shells:</info>", 2); $this->out(__d('cake_console', "<info>Available Shells:</info>"), 2);
} }
$shellList = $this->_getShellList(); $shellList = $this->_getShellList();
@ -140,8 +139,8 @@ class CommandListShell extends Shell {
$this->out(" " . $row); $this->out(" " . $row);
} }
$this->out(); $this->out();
$this->out("To run a command, type <info>cake shell_name [args]</info>"); $this->out(__d('cake_console', "To run a command, type <info>cake shell_name [args]</info>"));
$this->out("To get help on a specific command, type <info>cake shell_name --help</info>", 2); $this->out(__d('cake_console', "To get help on a specific command, type <info>cake shell_name --help</info>"), 2);
} }
/** /**
@ -212,7 +211,7 @@ class CommandListShell extends Shell {
*/ */
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
return $parser->description('Get the list of available shells for this CakePHP application.') return $parser->description(__d('cake_console', 'Get the list of available shells for this CakePHP application.'))
->addOption('xml', array( ->addOption('xml', array(
'help' => __d('cake_console', 'Get the listing as XML.'), 'help' => __d('cake_console', 'Get the listing as XML.'),
'boolean' => true 'boolean' => true

View file

@ -47,7 +47,7 @@ class ConsoleShell extends Shell {
public $models = array(); public $models = array();
/** /**
* Override intialize of the Shell * Override initialize of the Shell
* *
*/ */
public function initialize() { public function initialize() {
@ -61,8 +61,8 @@ class ConsoleShell extends Shell {
App::uses($class, 'Model'); App::uses($class, 'Model');
$this->{$class} = new $class(); $this->{$class} = new $class();
} }
$this->out('Model classes:'); $this->out(__d('cake_console', 'Model classes:'));
$this->out('--------------'); $this->hr();
foreach ($this->models as $model) { foreach ($this->models as $model) {
$this->out(" - {$model}"); $this->out(" - {$model}");
@ -151,7 +151,7 @@ class ConsoleShell extends Shell {
return true; return true;
break; break;
case 'models': case 'models':
$this->out('Model classes:'); $this->out(__d('cake_console', 'Model classes:'));
$this->hr(); $this->hr();
foreach ($this->models as $model) { foreach ($this->models as $model) {
$this->out(" - {$model}"); $this->out(" - {$model}");
@ -169,9 +169,10 @@ class ConsoleShell extends Shell {
if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations)) { if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations)) {
$this->{$modelA}->bindModel(array($association => array($modelB => array('className' => $modelB))), false); $this->{$modelA}->bindModel(array($association => array($modelB => array('className' => $modelB))), false);
$this->out("Created $association association between $modelA and $modelB"); $this->out(__d('cake_console', "Created %s association between %s and %s",
$association, $modelA, $modelB));
} else { } else {
$this->out("Please verify you are using valid models and association types"); $this->out(__d('cake_console', "Please verify you are using valid models and association types"));
} }
break; break;
case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true): case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true):
@ -196,9 +197,10 @@ class ConsoleShell extends Shell {
if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations) && $validCurrentAssociation) { if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations) && $validCurrentAssociation) {
$this->{$modelA}->unbindModel(array($association => array($modelB))); $this->{$modelA}->unbindModel(array($association => array($modelB)));
$this->out("Removed $association association between $modelA and $modelB"); $this->out(__d('cake_console', "Removed %s association between %s and %s",
$association, $modelA, $modelB));
} else { } else {
$this->out("Please verify you are using valid models, valid current association, and valid association types"); $this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types"));
} }
break; break;
case (strpos($command, "->find") > 0): case (strpos($command, "->find") > 0):
@ -248,10 +250,11 @@ class ConsoleShell extends Shell {
} }
} }
} else { } else {
$this->out("\nNo result set found"); $this->out();
$this->out(__d('cake_console', "No result set found"));
} }
} else { } else {
$this->out("$modelToCheck is not a valid model"); $this->out(__d('cake_console', "%s is not a valid model", $modelToCheck));
} }
break; break;
@ -267,7 +270,7 @@ class ConsoleShell extends Shell {
$data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data); $data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data);
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));"; $saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
@eval($saveCommand); @eval($saveCommand);
$this->out('Saved record for ' . $modelToSave); $this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
} }
break; break;
case (preg_match("/^(\w+) columns/", $command, $tmp) == true): case (preg_match("/^(\w+) columns/", $command, $tmp) == true):
@ -284,17 +287,16 @@ class ConsoleShell extends Shell {
} }
} }
} else { } else {
$this->out("Please verify that you selected a valid model"); $this->out(__d('cake_console', "Please verify that you selected a valid model"));
} }
break; break;
case (preg_match("/^routes\s+reload/i", $command, $tmp) == true): case (preg_match("/^routes\s+reload/i", $command, $tmp) == true):
$router = Router::getInstance(); $router = Router::getInstance();
if (!$this->_loadRoutes()) { if (!$this->_loadRoutes()) {
$this->out("There was an error loading the routes config. Please check that the file"); $this->out(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
$this->out("exists and is free of parse errors.");
break; break;
} }
$this->out("Routes configuration reloaded, " . count($router->routes) . " routes connected"); $this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count($router->routes)));
break; break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true): case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router = Router::getInstance(); $router = Router::getInstance();
@ -309,7 +311,8 @@ class ConsoleShell extends Shell {
$this->out(var_export(Router::parse($tmp[1]), true)); $this->out(var_export(Router::parse($tmp[1]), true));
break; break;
default: default:
$this->out("Invalid command\n"); $this->out(__d('cake_console', "Invalid command"));
$this->out();
break; break;
} }
$command = ''; $command = '';

View file

@ -137,7 +137,8 @@ class SchemaShell extends Shell {
if (!$snapshot && file_exists($this->Schema->path . DS . $this->params['file'])) { if (!$snapshot && file_exists($this->Schema->path . DS . $this->params['file'])) {
$snapshot = true; $snapshot = true;
$result = strtolower($this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's')); $prompt = __d('cake_console', "Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?");
$result = strtolower($this->in($prompt, array('o', 's', 'q'), 's'));
if ($result === 'q') { if ($result === 'q') {
return $this->_stop(); return $this->_stop();
} }
@ -453,7 +454,7 @@ class SchemaShell extends Shell {
'help' => __d('cake_console', 'Snapshot number to use/make.') 'help' => __d('cake_console', 'Snapshot number to use/make.')
); );
$dry = array( $dry = array(
'help' => 'Perform a dry run on create and update commands. Queries will be output instead of run.', 'help' => __d('cake_console', 'Perform a dry run on create and update commands. Queries will be output instead of run.'),
'boolean' => true 'boolean' => true
); );
$force = array( $force = array(
@ -467,10 +468,9 @@ class SchemaShell extends Shell {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
$parser->description( $parser->description(
'The Schema Shell generates a schema object from' . __d('cake_console', 'The Schema Shell generates a schema object from the database and updates the database from the schema.')
'the database and updates the database from the schema.'
)->addSubcommand('view', array( )->addSubcommand('view', array(
'help' => 'read and output the contents of a schema file', 'help' => __d('cake_console', 'Read and output the contents of a schema file'),
'parser' => array( 'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection'), 'options' => compact('plugin', 'path', 'file', 'name', 'connection'),
'arguments' => compact('name') 'arguments' => compact('name')

View file

@ -305,7 +305,7 @@ class ControllerTask extends BakeTask {
* @return string Baked controller * @return string Baked controller
*/ */
public function bake($controllerName, $actions = '', $helpers = null, $components = null) { public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
$this->out("\nBaking controller class for $controllerName...", 1, Shell::QUIET); $this->out("\n" . __d('cake_console', 'Baking controller class for %s...', $controllerName), 1, Shell::QUIET);
$isScaffold = ($actions === 'scaffold') ? true : false; $isScaffold = ($actions === 'scaffold') ? true : false;

View file

@ -94,19 +94,19 @@ class DbConfigTask extends Shell {
$name = ''; $name = '';
while ($name == '') { while ($name == '') {
$name = $this->in("Name:", null, 'default'); $name = $this->in(__d('cake_console', "Name:"), null, 'default');
if (preg_match('/[^a-z0-9_]/i', $name)) { if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = ''; $name = '';
$this->out('The name may only contain unaccented latin characters, numbers or underscores'); $this->out(__d('cake_console', 'The name may only contain unaccented latin characters, numbers or underscores'));
} else if (preg_match('/^[^a-z_]/i', $name)) { } else if (preg_match('/^[^a-z_]/i', $name)) {
$name = ''; $name = '';
$this->out('The name must start with an unaccented latin character or an underscore'); $this->out(__d('cake_console', 'The name must start with an unaccented latin character or an underscore'));
} }
} }
$driver = $this->in('Driver:', array('mssql', 'mysql', 'oracle', 'postgres', 'sqlite'), 'mysql'); $driver = $this->in(__d('cake_console', 'Driver:'), array('mssql', 'mysql', 'oracle', 'postgres', 'sqlite'), 'mysql');
$persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n'); $persistent = $this->in(__d('cake_console', 'Persistent Connection?'), array('y', 'n'), 'n');
if (strtolower($persistent) == 'n') { if (strtolower($persistent) == 'n') {
$persistent = 'false'; $persistent = 'false';
} else { } else {
@ -115,12 +115,12 @@ class DbConfigTask extends Shell {
$host = ''; $host = '';
while ($host == '') { while ($host == '') {
$host = $this->in('Database Host:', null, 'localhost'); $host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost');
} }
$port = ''; $port = '';
while ($port == '') { while ($port == '') {
$port = $this->in('Port?', null, 'n'); $port = $this->in(__d('cake_console', 'Port?'), null, 'n');
} }
if (strtolower($port) == 'n') { if (strtolower($port) == 'n') {
@ -129,16 +129,16 @@ class DbConfigTask extends Shell {
$login = ''; $login = '';
while ($login == '') { while ($login == '') {
$login = $this->in('User:', null, 'root'); $login = $this->in(__d('cake_console', 'User:'), null, 'root');
} }
$password = ''; $password = '';
$blankPassword = false; $blankPassword = false;
while ($password == '' && $blankPassword == false) { while ($password == '' && $blankPassword == false) {
$password = $this->in('Password:'); $password = $this->in(__d('cake_console', 'Password:'));
if ($password == '') { if ($password == '') {
$blank = $this->in('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n'); $blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n');
if ($blank == 'y') { if ($blank == 'y') {
$blankPassword = true; $blankPassword = true;
} }
@ -147,12 +147,12 @@ class DbConfigTask extends Shell {
$database = ''; $database = '';
while ($database == '') { while ($database == '') {
$database = $this->in('Database Name:', null, 'cake'); $database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake');
} }
$prefix = ''; $prefix = '';
while ($prefix == '') { while ($prefix == '') {
$prefix = $this->in('Table Prefix?', null, 'n'); $prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n');
} }
if (strtolower($prefix) == 'n') { if (strtolower($prefix) == 'n') {
$prefix = null; $prefix = null;
@ -160,7 +160,7 @@ class DbConfigTask extends Shell {
$encoding = ''; $encoding = '';
while ($encoding == '') { while ($encoding == '') {
$encoding = $this->in('Table encoding?', null, 'n'); $encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n');
} }
if (strtolower($encoding) == 'n') { if (strtolower($encoding) == 'n') {
$encoding = null; $encoding = null;
@ -169,7 +169,7 @@ class DbConfigTask extends Shell {
$schema = ''; $schema = '';
if ($driver == 'postgres') { if ($driver == 'postgres') {
while ($schema == '') { while ($schema == '') {
$schema = $this->in('Table schema?', null, 'n'); $schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n');
} }
} }
if (strtolower($schema) == 'n') { if (strtolower($schema) == 'n') {
@ -183,7 +183,7 @@ class DbConfigTask extends Shell {
} }
$dbConfigs[] = $config; $dbConfigs[] = $config;
$doneYet = $this->in('Do you wish to add another database configuration?', null, 'n'); $doneYet = $this->in(__d('cake_console', 'Do you wish to add another database configuration?'), null, 'n');
if (strtolower($doneYet == 'n')) { if (strtolower($doneYet == 'n')) {
$done = true; $done = true;
@ -205,35 +205,35 @@ class DbConfigTask extends Shell {
extract($config); extract($config);
$this->out(); $this->out();
$this->hr(); $this->hr();
$this->out('The following database configuration will be created:'); $this->out(__d('cake_console', 'The following database configuration will be created:'));
$this->hr(); $this->hr();
$this->out("Name: $name"); $this->out(__d('cake_console', "Name: %s", $name));
$this->out("Driver: $driver"); $this->out(__d('cake_console', "Driver: %s", $driver));
$this->out("Persistent: $persistent"); $this->out(__d('cake_console', "Persistent: %s", $persistent));
$this->out("Host: $host"); $this->out(__d('cake_console', "Host: %s", $host));
if ($port) { if ($port) {
$this->out("Port: $port"); $this->out(__d('cake_console', "Port: %s", $port));
} }
$this->out("User: $login"); $this->out(__d('cake_console', "User: %s", $login));
$this->out("Pass: " . str_repeat('*', strlen($password))); $this->out("Pass: %s", str_repeat('*', strlen($password))));
$this->out("Database: $database"); $this->out("Database: %s", $database));
if ($prefix) { if ($prefix) {
$this->out("Table prefix: $prefix"); $this->out(__d('cake_console', "Table prefix: %s", $prefix));
} }
if ($schema) { if ($schema) {
$this->out("Schema: $schema"); $this->out(__d('cake_console', "Schema: %s", $schema));
} }
if ($encoding) { if ($encoding) {
$this->out("Encoding: $encoding"); $this->out(__d('cake_console', "Encoding: %s", $encoding));
} }
$this->hr(); $this->hr();
$looksGood = $this->in('Look okay?', array('y', 'n'), 'y'); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) == 'y') { if (strtolower($looksGood) == 'y') {
return $config; return $config;
@ -249,7 +249,7 @@ class DbConfigTask extends Shell {
*/ */
public function bake($configs) { public function bake($configs) {
if (!is_dir($this->path)) { if (!is_dir($this->path)) {
$this->err($this->path . ' not found'); $this->err(__d('cake_console', '%s not found', $this->path));
return false; return false;
} }

View file

@ -83,7 +83,7 @@ class FixtureTask extends BakeTask {
'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'), 'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'),
'short' => 'p', 'short' => 'p',
))->addOption('records', array( ))->addOption('records', array(
'help' => 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10', 'help' => __d('cake_console', 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10'),
'short' => 'r', 'short' => 'r',
'boolean' => true 'boolean' => true
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));; ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));;
@ -91,7 +91,7 @@ class FixtureTask extends BakeTask {
/** /**
* Execution method always used for tasks * Execution method always used for tasks
* Handles dispatching to interactive, named, or all processess. * Handles dispatching to interactive, named, or all processeses.
* *
* @return void * @return void
*/ */
@ -137,7 +137,7 @@ class FixtureTask extends BakeTask {
protected function _interactive() { protected function _interactive() {
$this->DbConfig->interactive = $this->Model->interactive = $this->interactive = true; $this->DbConfig->interactive = $this->Model->interactive = $this->interactive = true;
$this->hr(); $this->hr();
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path)); $this->out(__d('cake_console', "Bake Fixture\nPath: %s", $this->path));
$this->hr(); $this->hr();
if (!isset($this->connection)) { if (!isset($this->connection)) {
@ -254,7 +254,7 @@ class FixtureTask extends BakeTask {
$this->Template->set($vars); $this->Template->set($vars);
$content = $this->Template->generate('classes', 'fixture'); $content = $this->Template->generate('classes', 'fixture');
$this->out("\nBaking test fixture for $model...", 1, Shell::QUIET); $this->out("\n" . __d('cake_console', 'Baking test fixture for %s...', $model), 1, Shell::QUIET);
$this->createFile($path . $filename, $content); $this->createFile($path . $filename, $content);
return $content; return $content;
} }

View file

@ -168,7 +168,7 @@ class ModelTask extends BakeTask {
*/ */
protected function _interactive() { protected function _interactive() {
$this->hr(); $this->hr();
$this->out(sprintf("Bake Model\nPath: %s", $this->path)); $this->out(__d('cake_console', "Bake Model\nPath: %s", $this->path));
$this->hr(); $this->hr();
$this->interactive = true; $this->interactive = true;
@ -215,7 +215,7 @@ class ModelTask extends BakeTask {
$this->hr(); $this->hr();
$this->out(__d('cake_console', 'The following Model will be created:')); $this->out(__d('cake_console', 'The following Model will be created:'));
$this->hr(); $this->hr();
$this->out("Name: " . $currentModelName); $this->out(__d('cake_console', "Name: %s", $currentModelName));
if ($this->connection !== 'default') { if ($this->connection !== 'default') {
$this->out(__d('cake_console', "DB Config: %s", $this->connection)); $this->out(__d('cake_console', "DB Config: %s", $this->connection));
@ -561,7 +561,7 @@ class ModelTask extends BakeTask {
* Find the hasAndBelongsToMany relations and add them to associations list * Find the hasAndBelongsToMany relations and add them to associations list
* *
* @param object $model Model instance being generated * @param object $model Model instance being generated
* @param array $associations Array of inprogress associations * @param array $associations Array of in-progress associations
* @return array $associations with hasAndBelongsToMany added in. * @return array $associations with hasAndBelongsToMany added in.
*/ */
public function findHasAndBelongsToMany($model, $associations) { public function findHasAndBelongsToMany($model, $associations) {
@ -738,7 +738,7 @@ class ModelTask extends BakeTask {
$path = $this->getPath(); $path = $this->getPath();
$filename = $path . $name . '.php'; $filename = $path . $name . '.php';
$this->out("\nBaking model class for $name...", 1, Shell::QUIET); $this->out("\n" . __d('cake_console', 'Baking model class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out); $this->createFile($filename, $out);
ClassRegistry::flush(); ClassRegistry::flush();
return $out; return $out;

View file

@ -185,10 +185,10 @@ class PluginTask extends Shell {
*/ */
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
return $parser->description( return $parser->description(__d('cake_console',
'Create the directory structure, AppModel and AppController classes for a new plugin. ' . 'Create the directory structure, AppModel and AppController classes for a new plugin. ' .
'Can create plugins in any of your bootstrapped plugin paths.' 'Can create plugins in any of your bootstrapped plugin paths.'
)->addArgument('name', array( ))->addArgument('name', array(
'help' => __d('cake_console', 'CamelCased name of the plugin to create.') 'help' => __d('cake_console', 'CamelCased name of the plugin to create.')
)); ));

View file

@ -357,7 +357,7 @@ class ProjectTask extends Shell {
} }
if ($this->interactive) { if ($this->interactive) {
$this->hr(); $this->hr();
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'); $this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'));
$this->out(__d('cake_console', 'What would you like the prefix route to be?')); $this->out(__d('cake_console', 'What would you like the prefix route to be?'));
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller')); $this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
while ($admin == '') { while ($admin == '') {
@ -365,7 +365,7 @@ class ProjectTask extends Shell {
} }
if ($this->cakeAdmin($admin) !== true) { if ($this->cakeAdmin($admin) !== true) {
$this->out(__d('cake_console', '<error>Unable to write to</error> /app/config/core.php.')); $this->out(__d('cake_console', '<error>Unable to write to</error> /app/config/core.php.'));
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'); $this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'));
$this->_stop(); $this->_stop();
} }
return $admin . '_'; return $admin . '_';

View file

@ -142,7 +142,7 @@ class TestTask extends BakeTask {
if ($this->plugin) { if ($this->plugin) {
$plugin = $this->plugin . '.'; $plugin = $this->plugin . '.';
} }
$this->out("\nBaking test case for $className $type...", 1, Shell::QUIET); $this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
$this->Template->set('fixtures', $this->_fixtures); $this->Template->set('fixtures', $this->_fixtures);
$this->Template->set('plugin', $plugin); $this->Template->set('plugin', $plugin);

View file

@ -367,7 +367,7 @@ class ViewTask extends BakeTask {
if (empty($content)) { if (empty($content)) {
return false; return false;
} }
$this->out("\nBaking `$action` view file...", 1, Shell::QUIET); $this->out("\n" . __d('cake_console', 'Baking `%s` view file...', $action), 1, Shell::QUIET);
$path = $this->getPath(); $path = $this->getPath();
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
return $this->createFile($filename, $content); return $this->createFile($filename, $content);

View file

@ -41,8 +41,8 @@ class TestsuiteShell extends Shell {
public function getOptionParser() { public function getOptionParser() {
$parser = new ConsoleOptionParser($this->name); $parser = new ConsoleOptionParser($this->name);
$parser->description(array( $parser->description(array(
'The CakePHP Testsuite allows you to run test cases from the command line', __d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
'If run with no command line arguments, a list of available core test cases will be shown' __d('cake_console', 'If run with no command line arguments, a list of available core test cases will be shown')
))->addArgument('category', array( ))->addArgument('category', array(
'help' => __d('cake_console', 'app, core or name of a plugin.'), 'help' => __d('cake_console', 'app, core or name of a plugin.'),
'required' => true 'required' => true
@ -157,7 +157,7 @@ class TestsuiteShell extends Shell {
} }
/** /**
* Initialization method installs Simpletest and loads all plugins * Initialization method installs PHPUnit and loads all plugins
* *
* @return void * @return void
*/ */

View file

@ -57,8 +57,7 @@ class ConsoleErrorHandler extends ErrorHandler {
*/ */
public static function handleException(Exception $exception) { public static function handleException(Exception $exception) {
$stderr = self::getStderr(); $stderr = self::getStderr();
$stderr->write(sprintf( $stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
__d('cake_console', "<error>Error:</error> %s\n%s"),
$exception->getMessage(), $exception->getMessage(),
$exception->getTraceAsString() $exception->getTraceAsString()
)); ));
@ -70,7 +69,7 @@ class ConsoleErrorHandler extends ErrorHandler {
* @param int $code Error code * @param int $code Error code
* @param string $description Description of the error. * @param string $description Description of the error.
* @param string $file The file the error occurred in. * @param string $file The file the error occurred in.
* @param int $line The line the error ocurrred on. * @param int $line The line the error occurred on.
* @param array $context The backtrace of the error. * @param array $context The backtrace of the error.
* @return void * @return void
*/ */

View file

@ -55,7 +55,7 @@ class ConsoleInputArgument {
/** /**
* Make a new Input Argument * Make a new Input Argument
* *
* @param mixed $name The long name of the option, or an array with all the properites. * @param mixed $name The long name of the option, or an array with all the properties.
* @param string $help The help text for this option * @param string $help The help text for this option
* @param boolean $required Whether this argument is required. Missing required args will trigger exceptions * @param boolean $required Whether this argument is required. Missing required args will trigger exceptions
* @param array $choices Valid choices for this option. * @param array $choices Valid choices for this option.
@ -139,8 +139,8 @@ class ConsoleInputArgument {
return true; return true;
} }
if (!in_array($value, $this->_choices)) { if (!in_array($value, $this->_choices)) {
throw new ConsoleException(sprintf( throw new ConsoleException(
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"'), __d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"',
$value, $this->_name, implode(', ', $this->_choices) $value, $this->_name, implode(', ', $this->_choices)
)); ));
} }

View file

@ -70,7 +70,7 @@ class ConsoleInputOption {
/** /**
* Make a new Input Option * Make a new Input Option
* *
* @param mixed $name The long name of the option, or an array with all the properites. * @param mixed $name The long name of the option, or an array with all the properties.
* @param string $short The short alias for this option * @param string $short The short alias for this option
* @param string $help The help text for this option * @param string $help The help text for this option
* @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens * @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
@ -179,8 +179,8 @@ class ConsoleInputOption {
return true; return true;
} }
if (!in_array($value, $this->_choices)) { if (!in_array($value, $this->_choices)) {
throw new ConsoleException(sprintf( throw new ConsoleException(
__d('cake_console', '"%s" is not a valid value for --%s. Please use one of "%s"'), __d('cake_console', '"%s" is not a valid value for --%s. Please use one of "%s"',
$value, $this->_name, implode(', ', $this->_choices) $value, $this->_name, implode(', ', $this->_choices)
)); ));
} }

View file

@ -50,7 +50,7 @@ class ConsoleInputSubcommand {
/** /**
* Make a new Subcommand * Make a new Subcommand
* *
* @param mixed $name The long name of the subcommand, or an array with all the properites. * @param mixed $name The long name of the subcommand, or an array with all the properties.
* @param string $help The help text for this option * @param string $help The help text for this option
* @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be * @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be
* used with ConsoleOptionParser::buildFromArray() * used with ConsoleOptionParser::buildFromArray()

View file

@ -86,9 +86,9 @@ class ConsoleOptionParser {
* *
* ### Options * ### Options
* *
* Named arguments come in two forms, long and short. Long arguments are preceeded * Named arguments come in two forms, long and short. Long arguments are preceded
* by two - and give a more verbose option name. i.e. `--version`. Short arguments are * by two - and give a more verbose option name. i.e. `--version`. Short arguments are
* preceeded by one - and are only one character long. They usually match with a long option, * preceded by one - and are only one character long. They usually match with a long option,
* and provide a more terse alternative. * and provide a more terse alternative.
* *
* ### Using Options * ### Using Options
@ -102,7 +102,7 @@ class ConsoleOptionParser {
* *
* `cake myshell command --connection default --name=something` * `cake myshell command --connection default --name=something`
* *
* Short options can be defined singally or in groups. * Short options can be defined signally or in groups.
* *
* `cake myshell command -cn` * `cake myshell command -cn`
* *
@ -127,7 +127,7 @@ class ConsoleOptionParser {
$this->addOption('help', array( $this->addOption('help', array(
'short' => 'h', 'short' => 'h',
'help' => 'Display this help.', 'help' => __d('cake_console', 'Display this help.'),
'boolean' => true 'boolean' => true
)); ));
@ -330,7 +330,7 @@ class ConsoleOptionParser {
} }
/** /**
* Add multiple arugments at once. Take an array of arugment defintions. * Add multiple arguments at once. Take an array of argument definitions.
* The keys are used as the argument names, and the values as params for the argument. * The keys are used as the argument names, and the values as params for the argument.
* *
* @param array $args Array of arguments to add. * @param array $args Array of arguments to add.

View file

@ -17,10 +17,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
/** /**
* Object wrapper for outputing information from a shell application. * Object wrapper for outputting information from a shell application.
* Can be connected to any stream resource that can be used with fopen() * Can be connected to any stream resource that can be used with fopen()
* *
* Can generate colourized output on consoles that support it. There are a few * Can generate colorized output on consoles that support it. There are a few
* built in styles * built in styles
* *
* - `error` Error messages. * - `error` Error messages.
@ -37,7 +37,7 @@
* *
* `$this->out('<warning>Overwrite:</warning> foo.php was overwritten.');` * `$this->out('<warning>Overwrite:</warning> foo.php was overwritten.');`
* *
* This would create orange 'Overwrite:' text, while the rest of the text would remain the normal colour. * This would create orange 'Overwrite:' text, while the rest of the text would remain the normal color.
* See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported * See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported
* at this time. * at this time.
* *
@ -55,7 +55,7 @@ class ConsoleOutput {
const PLAIN = 1; const PLAIN = 1;
/** /**
* Colour output - Convert known tags in to ANSI color escape codes. * Color output - Convert known tags in to ANSI color escape codes.
*/ */
const COLOR = 2; const COLOR = 2;
@ -79,7 +79,7 @@ class ConsoleOutput {
protected $_outputAs = self::COLOR; protected $_outputAs = self::COLOR;
/** /**
* text colors used in coloured output. * text colors used in colored output.
* *
* @var array * @var array
*/ */
@ -95,7 +95,7 @@ class ConsoleOutput {
); );
/** /**
* background colours used in coloured output. * background colors used in colored output.
* *
* @var array * @var array
*/ */
@ -111,7 +111,7 @@ class ConsoleOutput {
); );
/** /**
* formatting options for coloured output * formatting options for colored output
* *
* @var string * @var string
*/ */
@ -140,7 +140,7 @@ class ConsoleOutput {
/** /**
* Construct the output object. * Construct the output object.
* *
* Checks for a pretty console enviornment. Ansicon allows pretty consoles * Checks for a pretty console environment. Ansicon allows pretty consoles
* on windows, and is supported. * on windows, and is supported.
* *
* @param string $stream The identifier of the stream to write output to. * @param string $stream The identifier of the stream to write output to.
@ -267,7 +267,7 @@ class ConsoleOutput {
/** /**
* Get/Set the output type to use. The output type how formatting tags are treated. * Get/Set the output type to use. The output type how formatting tags are treated.
* *
* @param int $type The output type to use. Should be one of the class contstants. * @param int $type The output type to use. Should be one of the class constants.
* @return mixed Either null or the value if getting. * @return mixed Either null or the value if getting.
*/ */
public function outputAs($type = null) { public function outputAs($type = null) {

View file

@ -23,7 +23,7 @@ App::uses('String', 'Utility');
* Generally not directly used. Using $parser->help($command, 'xml'); is usually * Generally not directly used. Using $parser->help($command, 'xml'); is usually
* how you would access help. Or via the `--help=xml` option on the command line. * how you would access help. Or via the `--help=xml` option on the command line.
* *
* Xml output is useful for intergration with other tools like IDE's or other build tools. * Xml output is useful for integration with other tools like IDE's or other build tools.
* *
* @package cake.console.libs * @package cake.console.libs
* @since CakePHP(tm) v 2.0 * @since CakePHP(tm) v 2.0
@ -52,12 +52,12 @@ class HelpFormatter {
$out[] = String::wrap($description, $width); $out[] = String::wrap($description, $width);
$out[] = ''; $out[] = '';
} }
$out[] = '<info>Usage:</info>'; $out[] = __d('cake_console', '<info>Usage:</info>');
$out[] = $this->_generateUsage(); $out[] = $this->_generateUsage();
$out[] = ''; $out[] = '';
$subcommands = $parser->subcommands(); $subcommands = $parser->subcommands();
if (!empty($subcommands)) { if (!empty($subcommands)) {
$out[] = '<info>Subcommands:</info>'; $out[] = __d('cake_console', '<info>Subcommands:</info>');
$out[] = ''; $out[] = '';
$max = $this->_getMaxLength($subcommands) + 2; $max = $this->_getMaxLength($subcommands) + 2;
foreach ($subcommands as $command) { foreach ($subcommands as $command) {
@ -68,17 +68,14 @@ class HelpFormatter {
)); ));
} }
$out[] = ''; $out[] = '';
$out[] = sprintf( $out[] = __d('cake_console', 'To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>', $parser->command());
__d('cake_console', 'To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>'),
$parser->command()
);
$out[] = ''; $out[] = '';
} }
$options = $parser->options(); $options = $parser->options();
if (!empty($options)) { if (!empty($options)) {
$max = $this->_getMaxLength($options) + 8; $max = $this->_getMaxLength($options) + 8;
$out[] = '<info>Options:</info>'; $out[] = __d('cake_console', '<info>Options:</info>');
$out[] = ''; $out[] = '';
foreach ($options as $option) { foreach ($options as $option) {
$out[] = String::wrap($option->help($max), array( $out[] = String::wrap($option->help($max), array(
@ -93,7 +90,7 @@ class HelpFormatter {
$arguments = $parser->arguments(); $arguments = $parser->arguments();
if (!empty($arguments)) { if (!empty($arguments)) {
$max = $this->_getMaxLength($arguments) + 2; $max = $this->_getMaxLength($arguments) + 2;
$out[] = '<info>Arguments:</info>'; $out[] = __d('cake_console', '<info>Arguments:</info>');
$out[] = ''; $out[] = '';
foreach ($arguments as $argument) { foreach ($arguments as $argument) {
$out[] = String::wrap($argument->help($max), array( $out[] = String::wrap($argument->help($max), array(
@ -114,7 +111,7 @@ class HelpFormatter {
/** /**
* Generate the usage for a shell based on its arguments and options. * Generate the usage for a shell based on its arguments and options.
* Usage strings favour short options over the long ones. and optional args will * Usage strings favor short options over the long ones. and optional args will
* be indicated with [] * be indicated with []
* *
* @return string * @return string
@ -156,7 +153,7 @@ class HelpFormatter {
public function xml($string = true) { public function xml($string = true) {
$parser = $this->_parser; $parser = $this->_parser;
$xml = new SimpleXmlElement('<shell></shell>'); $xml = new SimpleXmlElement('<shell></shell>');
$xml->addChild('commmand', $parser->command()); $xml->addChild('command', $parser->command());
$xml->addChild('description', $parser->description()); $xml->addChild('description', $parser->description());
$xml->addChild('epilog', $parser->epilog()); $xml->addChild('epilog', $parser->epilog());

View file

@ -188,7 +188,7 @@ class Shell extends Object {
/** /**
* Starts up the Shell * Starts up the Shell
* allows for checking and configuring prior to command or main execution * allows for checking and configuring prior to command or main execution
* can be overriden in subclasses * can be overridden in subclasses
* *
*/ */
public function startup() { public function startup() {
@ -201,10 +201,10 @@ class Shell extends Object {
*/ */
protected function _welcome() { protected function _welcome() {
$this->out(); $this->out();
$this->out('<info>Welcome to CakePHP v' . Configure::version() . ' Console</info>'); $this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
$this->hr(); $this->hr();
$this->out('App : '. APP_DIR); $this->out(__d('cake_console', 'App : %s', APP_DIR));
$this->out('Path: '. APP_PATH); $this->out(__d('cake_console', 'Path: %s', APP_PATH));
$this->hr(); $this->hr();
} }
@ -296,7 +296,7 @@ class Shell extends Object {
* *
* ### Usage: * ### Usage:
* *
* With a string commmand: * With a string command:
* *
* `return $this->dispatchShell('schema create DbAcl');` * `return $this->dispatchShell('schema create DbAcl');`
* *
@ -578,7 +578,7 @@ class Shell extends Object {
*/ */
public function clear() { public function clear() {
if (empty($this->params['noclear'])) { if (empty($this->params['noclear'])) {
if ( DS === '/') { if (DS === '/') {
passthru('clear'); passthru('clear');
} else { } else {
passthru('cls'); passthru('cls');
@ -600,7 +600,7 @@ class Shell extends Object {
if (is_file($path) && $this->interactive === true) { if (is_file($path) && $this->interactive === true) {
$this->out(__d('cake_console', '<warning>File `%s` exists</warning>', $path)); $this->out(__d('cake_console', '<warning>File `%s` exists</warning>', $path));
$key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') { if (strtolower($key) == 'q') {
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2); $this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
@ -636,13 +636,13 @@ class Shell extends Object {
if (@include 'PHPUnit' . DS . 'Autoload.php') { if (@include 'PHPUnit' . DS . 'Autoload.php') {
return true; return true;
} }
$prompt = 'PHPUnit is not installed. Do you want to bake unit test files anyway?'; $prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?');
$unitTest = $this->in($prompt, array('y','n'), 'y'); $unitTest = $this->in($prompt, array('y','n'), 'y');
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes'; $result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
if ($result) { if ($result) {
$this->out(); $this->out();
$this->out('You can download PHPUnit from http://phpunit.de'); $this->out(__d('cake_console', 'You can download PHPUnit from %s', 'http://phpunit.de'));
} }
return $result; return $result;
} }

View file

@ -99,13 +99,13 @@ class ShellDispatcher {
*/ */
protected function _initEnvironment() { protected function _initEnvironment() {
if (!$this->__bootstrap()) { if (!$this->__bootstrap()) {
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'cake' . DS . 'libs exists in ' . CAKE_CORE_INCLUDE_PATH; $message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
throw new CakeException($message); throw new CakeException($message);
} }
if (!isset($this->args[0]) || !isset($this->params['working'])) { if (!isset($this->args[0]) || !isset($this->params['working'])) {
$message = "This file has been loaded incorrectly and cannot continue.\n" . $message = "This file has been loaded incorrectly and cannot continue.\n" .
"Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" . "Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in your system path,\n" .
"and check the cookbook for the correct usage of this command.\n" . "and check the cookbook for the correct usage of this command.\n" .
"(http://book.cakephp.org/)"; "(http://book.cakephp.org/)";
throw new CakeException($message); throw new CakeException($message);