Browse Source

Fixes #4292: The error messages for console commands will not be translated

tags/2.0.0
Qiang Xue 10 years ago
parent
commit
de87f43d70
  1. 2
      framework/console/Application.php
  2. 10
      framework/console/controllers/HelpController.php

2
framework/console/Application.php

@ -160,7 +160,7 @@ class Application extends \yii\base\Application
try {
return (int)parent::runAction($route, $params);
} catch (InvalidRouteException $e) {
throw new Exception(Yii::t('yii', 'Unknown command "{command}".', ['command' => $route]), 0, $e);
throw new Exception("Unknown command \"$route\".", 0, $e);
}
}

10
framework/console/controllers/HelpController.php

@ -51,9 +51,8 @@ class HelpController extends Controller
if ($command !== null) {
$result = Yii::$app->createController($command);
if ($result === false) {
throw new Exception(Yii::t('yii', 'No help for unknown command "{command}".', [
'command' => $this->ansiFormat($command, Console::FG_YELLOW),
]));
$name = $this->ansiFormat($command, Console::FG_RED);
throw new Exception("No help for unknown command \"$name\".");
}
list($controller, $actionID) = $result;
@ -251,9 +250,8 @@ class HelpController extends Controller
{
$action = $controller->createAction($actionID);
if ($action === null) {
throw new Exception(Yii::t('yii', 'No help for unknown sub-command "{command}".', [
'command' => rtrim($controller->getUniqueId() . '/' . $actionID, '/'),
]));
$name = $this->ansiFormat(rtrim($controller->getUniqueId() . '/' . $actionID, '/'), Console::FG_RED);
throw new Exception("No help for unknown sub-command \"$name\".");
}
$description = $controller->getActionHelp($action);

Loading…
Cancel
Save