Commit 3c1452e8 by Qiang Xue

Changed the separator of message category.

parent 54ee8c44
......@@ -177,7 +177,7 @@ class Controller extends Component
}
if ($missing !== array()) {
throw new InvalidRequestException(Yii::t('yii:Missing required parameters: {params}', array(
throw new InvalidRequestException(Yii::t('yii|Missing required parameters: {params}', array(
'{params}' => implode(', ', $missing),
)));
}
......
......@@ -22,7 +22,7 @@ class Exception extends \Exception
*/
public function getName()
{
return \Yii::t('yii:Exception');
return \Yii::t('yii|Exception');
}
}
......@@ -104,6 +104,6 @@ class HttpException extends UserException
if(isset($httpCodes[$this->statusCode]))
return $httpCodes[$this->statusCode];
else
return \Yii::t('yii:Error');
return \Yii::t('yii|Error');
}
}
......@@ -22,7 +22,7 @@ class InvalidCallException extends Exception
*/
public function getName()
{
return \Yii::t('yii:Invalid Call');
return \Yii::t('yii|Invalid Call');
}
}
......@@ -22,7 +22,7 @@ class InvalidConfigException extends Exception
*/
public function getName()
{
return \Yii::t('yii:Invalid Configuration');
return \Yii::t('yii|Invalid Configuration');
}
}
......@@ -22,7 +22,7 @@ class InvalidRequestException extends UserException
*/
public function getName()
{
return \Yii::t('yii:Invalid Request');
return \Yii::t('yii|Invalid Request');
}
}
......@@ -22,7 +22,7 @@ class InvalidRouteException extends UserException
*/
public function getName()
{
return \Yii::t('yii:Invalid Route');
return \Yii::t('yii|Invalid Route');
}
}
......@@ -22,7 +22,7 @@ class NotSupportedException extends Exception
*/
public function getName()
{
return \Yii::t('yii:Not Supported');
return \Yii::t('yii|Not Supported');
}
}
......@@ -79,7 +79,7 @@ class SecurityManager extends Component
if (!empty($value)) {
$this->_validationKey = $value;
} else {
throw new CException(Yii::t('yii:SecurityManager.validationKey cannot be empty.'));
throw new CException(Yii::t('yii|SecurityManager.validationKey cannot be empty.'));
}
}
......@@ -112,7 +112,7 @@ class SecurityManager extends Component
if (!empty($value)) {
$this->_encryptionKey = $value;
} else {
throw new CException(Yii::t('yii:SecurityManager.encryptionKey cannot be empty.'));
throw new CException(Yii::t('yii|SecurityManager.encryptionKey cannot be empty.'));
}
}
......@@ -191,12 +191,12 @@ class SecurityManager extends Component
}
if ($module === false) {
throw new CException(Yii::t('yii:Failed to initialize the mcrypt module.'));
throw new CException(Yii::t('yii|Failed to initialize the mcrypt module.'));
}
return $module;
} else {
throw new CException(Yii::t('yii:SecurityManager requires PHP mcrypt extension to be loaded in order to use data encryption feature.'));
throw new CException(Yii::t('yii|SecurityManager requires PHP mcrypt extension to be loaded in order to use data encryption feature.'));
}
}
......
......@@ -22,7 +22,7 @@ class UnknownMethodException extends Exception
*/
public function getName()
{
return \Yii::t('yii:Unknown Method');
return \Yii::t('yii|Unknown Method');
}
}
......@@ -22,7 +22,7 @@ class UnknownPropertyException extends Exception
*/
public function getName()
{
return \Yii::t('yii:Unknown Property');
return \Yii::t('yii|Unknown Property');
}
}
......@@ -366,7 +366,7 @@ class UrlManager extends Component
return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r;
}
if($this->useStrictParsing)
throw new HttpException(404,Yii::t('yii:Unable to resolve the request "{route}".',
throw new HttpException(404,Yii::t('yii|Unable to resolve the request "{route}".',
array('{route}'=>$pathInfo)));
else
return $pathInfo;
......@@ -502,7 +502,7 @@ class UrlManager extends Component
if($value===self::PATH_FORMAT || $value===self::GET_FORMAT)
$this->_urlFormat=$value;
else
throw new CException(Yii::t('yii:CUrlManager.UrlFormat must be either "path" or "get".'));
throw new CException(Yii::t('yii|CUrlManager.UrlFormat must be either "path" or "get".'));
}
}
......@@ -685,7 +685,7 @@ class CUrlRule extends CBaseUrlRule
$this->routePattern='/^'.strtr($this->route,$tr2).'$/u';
if(YII_DEBUG && @preg_match($this->pattern,'test')===false)
throw new CException(Yii::t('yii:The URL pattern "{pattern}" for route "{route}" is not a valid regular expression.',
throw new CException(Yii::t('yii|The URL pattern "{pattern}" for route "{route}" is not a valid regular expression.',
array('{route}'=>$route,'{pattern}'=>$pattern)));
}
......
......@@ -93,7 +93,7 @@ class Application extends \yii\base\Application
if ($request->getIsConsoleRequest()) {
return $this->runAction($request->route, $request->params);
} else {
throw new Exception(\Yii::t('yii:this script must be run from the command line.'));
throw new Exception(\Yii::t('yii|this script must be run from the command line.'));
}
}
......@@ -112,7 +112,7 @@ class Application extends \yii\base\Application
try {
return parent::runAction($route, $params);
} catch (InvalidRouteException $e) {
throw new Exception(\Yii::t('yii:Unknown command "{command}".', array('{command}' => $route)));
throw new Exception(\Yii::t('yii|Unknown command "{command}".', array('{command}' => $route)));
}
}
......
......@@ -85,7 +85,7 @@ class Controller extends \yii\base\Controller
$args = isset($params[Request::ANONYMOUS_PARAMS]) ? $params[Request::ANONYMOUS_PARAMS] : array();
unset($params[Request::ANONYMOUS_PARAMS]);
if ($params !== array()) {
throw new Exception(Yii::t('yii:Unknown options: {params}', array(
throw new Exception(Yii::t('yii|Unknown options: {params}', array(
'{params}' => implode(', ', array_keys($params)),
)));
}
......@@ -109,7 +109,7 @@ class Controller extends \yii\base\Controller
}
if ($missing !== array()) {
throw new Exception(Yii::t('yii:Missing required arguments: {params}', array(
throw new Exception(Yii::t('yii|Missing required arguments: {params}', array(
'{params}' => implode(', ', $missing),
)));
}
......
......@@ -24,7 +24,7 @@ class Exception extends UserException
*/
public function getName()
{
return \Yii::t('yii:Error');
return \Yii::t('yii|Error');
}
}
......@@ -57,7 +57,7 @@ class HelpController extends Controller
if ($command !== null) {
$result = Yii::$application->createController($command);
if ($result === false) {
throw new Exception(Yii::t('yii:No help for unknown command "{command}".', array(
throw new Exception(Yii::t('yii|No help for unknown command "{command}".', array(
'{command}' => $command,
)));
}
......@@ -241,7 +241,7 @@ class HelpController extends Controller
{
$action = $controller->createAction($actionID);
if ($action === null) {
throw new Exception(Yii::t('yii:No help for unknown sub-command "{command}".', array(
throw new Exception(Yii::t('yii|No help for unknown sub-command "{command}".', array(
'{command}' => rtrim($controller->getUniqueId() . '/' . $actionID, '/'),
)));
}
......
......@@ -40,6 +40,6 @@ class Exception extends \yii\base\Exception
*/
public function getName()
{
return \Yii::t('yii:Database Exception');
return \Yii::t('yii|Database Exception');
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ class I18N extends Component
$language = Yii::$application->language;
}
if (preg_match('/^([\w\-]+):(.*)/', $message, $matches)) {
if (preg_match('/^([\w\-\.]+)\|(.*)/', $message, $matches)) {
$category = $matches[1];
$message = $matches[2];
} else {
......
......@@ -50,7 +50,7 @@ class EmailTarget extends Target
$body .= $this->formatMessage($message);
}
$body = wordwrap($body, 70);
$subject = $this->subject === null ? \Yii::t('yii:Application Log') : $this->subject;
$subject = $this->subject === null ? \Yii::t('yii|Application Log') : $this->subject;
foreach ($this->emails as $email) {
$this->sendEmail($subject, $body, $email, $this->sentFrom, $this->headers);
}
......
......@@ -61,7 +61,7 @@ class CProfileLogRoute extends CWebLogRoute
if ($value === 'summary' || $value === 'callstack')
$this->_report = $value;
else
throw new CException(Yii::t('yii:CProfileLogRoute.report "{report}" is invalid. Valid values include "summary" and "callstack".',
throw new CException(Yii::t('yii|CProfileLogRoute.report "{report}" is invalid. Valid values include "summary" and "callstack".',
array('{report}' => $value)));
}
......@@ -108,7 +108,7 @@ class CProfileLogRoute extends CWebLogRoute
$results[$last[4]] = array($token, $delta, count($stack));
} else
{
throw new CException(Yii::t('yii:CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.',
throw new CException(Yii::t('yii|CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.',
array('{token}' => $token)));
}
}
......@@ -151,7 +151,7 @@ class CProfileLogRoute extends CWebLogRoute
else
$results[$token] = array($token, 1, $delta, $delta, $delta);
} else
throw new CException(Yii::t('yii:CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.',
throw new CException(Yii::t('yii|CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.',
array('{token}' => $token)));
}
}
......
......@@ -54,7 +54,7 @@ class BooleanValidator extends Validator
}
if (!$this->strict && $value != $this->trueValue && $value != $this->falseValue
|| $this->strict && $value !== $this->trueValue && $value !== $this->falseValue) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} must be either {true} or {false}.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} must be either {true} or {false}.');
$this->addError($object, $attribute, $message, array(
'{true}' => $this->trueValue,
'{false}' => $this->falseValue,
......@@ -70,7 +70,7 @@ class BooleanValidator extends Validator
*/
public function clientValidateAttribute($object, $attribute)
{
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} must be either {true} or {false}.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} must be either {true} or {false}.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
......
......@@ -49,7 +49,7 @@ class CaptchaValidator extends Validator
}
$captcha = $this->getCaptchaAction();
if (!$captcha->validate($value, $this->caseSensitive)) {
$message = $this->message !== null ? $this->message : \Yii::t('yii:The verification code is incorrect.');
$message = $this->message !== null ? $this->message : \Yii::t('yii|The verification code is incorrect.');
$this->addError($object, $attribute, $message);
}
}
......@@ -85,7 +85,7 @@ class CaptchaValidator extends Validator
public function clientValidateAttribute($object, $attribute)
{
$captcha = $this->getCaptchaAction();
$message = $this->message !== null ? $this->message : \Yii::t('yii:The verification code is incorrect.');
$message = $this->message !== null ? $this->message : \Yii::t('yii|The verification code is incorrect.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
......
......@@ -96,37 +96,37 @@ class CompareValidator extends Validator
case '=':
case '==':
if (($this->strict && $value !== $compareValue) || (!$this->strict && $value != $compareValue)) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must be repeated exactly.');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must be repeated exactly.');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel));
}
break;
case '!=':
if (($this->strict && $value === $compareValue) || (!$this->strict && $value == $compareValue)) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must not be equal to "{compareValue}".');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must not be equal to "{compareValue}".');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel, '{compareValue}' => $compareValue));
}
break;
case '>':
if ($value <= $compareValue) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must be greater than "{compareValue}".');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must be greater than "{compareValue}".');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel, '{compareValue}' => $compareValue));
}
break;
case '>=':
if ($value < $compareValue) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must be greater than or equal to "{compareValue}".');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must be greater than or equal to "{compareValue}".');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel, '{compareValue}' => $compareValue));
}
break;
case '<':
if ($value >= $compareValue) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must be less than "{compareValue}".');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must be less than "{compareValue}".');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel, '{compareValue}' => $compareValue));
}
break;
case '<=':
if ($value > $compareValue) {
$message = ($this->message !== null) ? $this->message : Yii::t('yii:{attribute} must be less than or equal to "{compareValue}".');
$message = ($this->message !== null) ? $this->message : Yii::t('yii|{attribute} must be less than or equal to "{compareValue}".');
$this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareLabel, '{compareValue}' => $compareValue));
}
break;
......@@ -158,37 +158,37 @@ class CompareValidator extends Validator
case '=':
case '==':
if ($message === null) {
$message = Yii::t('yii:{attribute} must be repeated exactly.');
$message = Yii::t('yii|{attribute} must be repeated exactly.');
}
$condition = 'value!=' . $compareValue;
break;
case '!=':
if ($message === null) {
$message = Yii::t('yii:{attribute} must not be equal to "{compareValue}".');
$message = Yii::t('yii|{attribute} must not be equal to "{compareValue}".');
}
$condition = 'value==' . $compareValue;
break;
case '>':
if ($message === null) {
$message = Yii::t('yii:{attribute} must be greater than "{compareValue}".');
$message = Yii::t('yii|{attribute} must be greater than "{compareValue}".');
}
$condition = 'value<=' . $compareValue;
break;
case '>=':
if ($message === null) {
$message = Yii::t('yii:{attribute} must be greater than or equal to "{compareValue}".');
$message = Yii::t('yii|{attribute} must be greater than or equal to "{compareValue}".');
}
$condition = 'value<' . $compareValue;
break;
case '<':
if ($message === null) {
$message = Yii::t('yii:{attribute} must be less than "{compareValue}".');
$message = Yii::t('yii|{attribute} must be less than "{compareValue}".');
}
$condition = 'value>=' . $compareValue;
break;
case '<=':
if ($message === null) {
$message = Yii::t('yii:{attribute} must be less than or equal to "{compareValue}".');
$message = Yii::t('yii|{attribute} must be less than or equal to "{compareValue}".');
}
$condition = 'value>' . $compareValue;
break;
......
......@@ -66,7 +66,7 @@ class DateValidator extends Validator
}
if (!$valid) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:The format of {attribute} is invalid.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|The format of {attribute} is invalid.');
$this->addError($object, $attribute, $message);
}
}
......
......@@ -63,7 +63,7 @@ class EmailValidator extends Validator
return;
}
if (!$this->validateValue($value)) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is not a valid email address.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is not a valid email address.');
$this->addError($object, $attribute, $message);
}
}
......@@ -100,7 +100,7 @@ class EmailValidator extends Validator
*/
public function clientValidateAttribute($object, $attribute)
{
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is not a valid email address.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is not a valid email address.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
......
......@@ -68,7 +68,7 @@ class ExistValidator extends Validator
$query = $className::find();
$query->where(array($column->name => $value));
if (!$query->exists()) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} "{value}" is invalid.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} "{value}" is invalid.');
$this->addError($object, $attribute, $message);
}
}
......
......@@ -115,7 +115,7 @@ class CFileValidator extends Validator
return $this->emptyAttribute($object, $attribute);
if (count($files) > $this->maxFiles)
{
$message = $this->tooMany !== null ? $this->tooMany : \Yii::t('yii:{attribute} cannot accept more than {limit} files.');
$message = $this->tooMany !== null ? $this->tooMany : \Yii::t('yii|{attribute} cannot accept more than {limit} files.');
$this->addError($object, $attribute, $message, array('{attribute}' => $attribute, '{limit}' => $this->maxFiles));
} else
foreach ($files as $file)
......@@ -145,20 +145,20 @@ class CFileValidator extends Validator
return $this->emptyAttribute($object, $attribute);
elseif ($error == UPLOAD_ERR_INI_SIZE || $error == UPLOAD_ERR_FORM_SIZE || $this->maxSize !== null && $file->getSize() > $this->maxSize)
{
$message = $this->tooLarge !== null ? $this->tooLarge : \Yii::t('yii:The file "{file}" is too large. Its size cannot exceed {limit} bytes.');
$message = $this->tooLarge !== null ? $this->tooLarge : \Yii::t('yii|The file "{file}" is too large. Its size cannot exceed {limit} bytes.');
$this->addError($object, $attribute, $message, array('{file}' => $file->getName(), '{limit}' => $this->getSizeLimit()));
} elseif ($error == UPLOAD_ERR_PARTIAL)
throw new CException(\Yii::t('yii:The file "{file}" was only partially uploaded.', array('{file}' => $file->getName())));
throw new CException(\Yii::t('yii|The file "{file}" was only partially uploaded.', array('{file}' => $file->getName())));
elseif ($error == UPLOAD_ERR_NO_TMP_DIR)
throw new CException(\Yii::t('yii:Missing the temporary folder to store the uploaded file "{file}".', array('{file}' => $file->getName())));
throw new CException(\Yii::t('yii|Missing the temporary folder to store the uploaded file "{file}".', array('{file}' => $file->getName())));
elseif ($error == UPLOAD_ERR_CANT_WRITE)
throw new CException(\Yii::t('yii:Failed to write the uploaded file "{file}" to disk.', array('{file}' => $file->getName())));
throw new CException(\Yii::t('yii|Failed to write the uploaded file "{file}" to disk.', array('{file}' => $file->getName())));
elseif (defined('UPLOAD_ERR_EXTENSION') && $error == UPLOAD_ERR_EXTENSION) // available for PHP 5.2.0 or above
throw new CException(\Yii::t('yii:File upload was stopped by extension.'));
throw new CException(\Yii::t('yii|File upload was stopped by extension.'));
if ($this->minSize !== null && $file->getSize() < $this->minSize)
{
$message = $this->tooSmall !== null ? $this->tooSmall : \Yii::t('yii:The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.');
$message = $this->tooSmall !== null ? $this->tooSmall : \Yii::t('yii|The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.');
$this->addError($object, $attribute, $message, array('{file}' => $file->getName(), '{limit}' => $this->minSize));
}
......@@ -170,7 +170,7 @@ class CFileValidator extends Validator
$types = $this->types;
if (!in_array(strtolower($file->getExtensionName()), $types))
{
$message = $this->wrongType !== null ? $this->wrongType : \Yii::t('yii:The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.');
$message = $this->wrongType !== null ? $this->wrongType : \Yii::t('yii|The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.');
$this->addError($object, $attribute, $message, array('{file}' => $file->getName(), '{extensions}' => implode(', ', $types)));
}
}
......@@ -185,7 +185,7 @@ class CFileValidator extends Validator
{
if (!$this->allowEmpty)
{
$message = $this->message !== null ? $this->message : \Yii::t('yii:{attribute} cannot be blank.');
$message = $this->message !== null ? $this->message : \Yii::t('yii|{attribute} cannot be blank.');
$this->addError($object, $attribute, $message);
}
}
......
......@@ -73,21 +73,21 @@ class NumberValidator extends Validator
}
if ($this->integerOnly) {
if (!preg_match($this->integerPattern, "$value")) {
$message = $this->message !== null ? $this->message : Yii::t('yii:{attribute} must be an integer.');
$message = $this->message !== null ? $this->message : Yii::t('yii|{attribute} must be an integer.');
$this->addError($object, $attribute, $message);
}
} else {
if (!preg_match($this->numberPattern, "$value")) {
$message = $this->message !== null ? $this->message : Yii::t('yii:{attribute} must be a number.');
$message = $this->message !== null ? $this->message : Yii::t('yii|{attribute} must be a number.');
$this->addError($object, $attribute, $message);
}
}
if ($this->min !== null && $value < $this->min) {
$message = $this->tooSmall !== null ? $this->tooSmall : Yii::t('yii:{attribute} is too small (minimum is {min}).');
$message = $this->tooSmall !== null ? $this->tooSmall : Yii::t('yii|{attribute} is too small (minimum is {min}).');
$this->addError($object, $attribute, $message, array('{min}' => $this->min));
}
if ($this->max !== null && $value > $this->max) {
$message = $this->tooBig !== null ? $this->tooBig : Yii::t('yii:{attribute} is too big (maximum is {max}).');
$message = $this->tooBig !== null ? $this->tooBig : Yii::t('yii|{attribute} is too big (maximum is {max}).');
$this->addError($object, $attribute, $message, array('{max}' => $this->max));
}
}
......@@ -103,8 +103,8 @@ class NumberValidator extends Validator
$label = $object->getAttributeLabel($attribute);
if (($message = $this->message) === null) {
$message = $this->integerOnly ? Yii::t('yii:{attribute} must be an integer.')
: Yii::t('yii:{attribute} must be a number.');
$message = $this->integerOnly ? Yii::t('yii|{attribute} must be an integer.')
: Yii::t('yii|{attribute} must be a number.');
}
$message = strtr($message, array(
'{attribute}' => $label,
......@@ -118,7 +118,7 @@ if(!value.match($pattern)) {
";
if ($this->min !== null) {
if (($tooSmall = $this->tooSmall) === null) {
$tooSmall = Yii::t('yii:{attribute} is too small (minimum is {min}).');
$tooSmall = Yii::t('yii|{attribute} is too small (minimum is {min}).');
}
$tooSmall = strtr($tooSmall, array(
'{attribute}' => $label,
......@@ -133,7 +133,7 @@ if(value<{$this->min}) {
}
if ($this->max !== null) {
if (($tooBig = $this->tooBig) === null) {
$tooBig = Yii::t('yii:{attribute} is too big (maximum is {max}).');
$tooBig = Yii::t('yii|{attribute} is too big (maximum is {max}).');
}
$tooBig = strtr($tooBig, array(
'{attribute}' => $label,
......
......@@ -58,10 +58,10 @@ class RangeValidator extends Validator
throw new InvalidConfigException('The "range" property must be specified as an array.');
}
if (!$this->not && !in_array($value, $this->range, $this->strict)) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} should be in the list.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} should be in the list.');
$this->addError($object, $attribute, $message);
} elseif ($this->not && in_array($value, $this->range, $this->strict)) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} should NOT be in the list.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} should NOT be in the list.');
$this->addError($object, $attribute, $message);
}
}
......@@ -80,7 +80,7 @@ class RangeValidator extends Validator
}
if (($message = $this->message) === null) {
$message = $this->not ? \Yii::t('yii:{attribute} should NOT be in the list.') : \Yii::t('yii:{attribute} should be in the list.');
$message = $this->not ? \Yii::t('yii|{attribute} should NOT be in the list.') : \Yii::t('yii|{attribute} should be in the list.');
}
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
......
......@@ -51,7 +51,7 @@ class RegularExpressionValidator extends Validator
throw new \yii\base\Exception('The "pattern" property must be specified with a valid regular expression.');
}
if ((!$this->not && !preg_match($this->pattern, $value)) || ($this->not && preg_match($this->pattern, $value))) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is invalid.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is invalid.');
$this->addError($object, $attribute, $message);
}
}
......@@ -69,7 +69,7 @@ class RegularExpressionValidator extends Validator
throw new \yii\base\Exception('The "pattern" property must be specified with a valid regular expression.');
}
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is invalid.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is invalid.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
......
......@@ -47,12 +47,12 @@ class RequiredValidator extends Validator
$value = $object->$attribute;
if ($this->requiredValue === null) {
if ($this->strict && $value === null || !$this->strict && $this->isEmpty($value, true)) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} cannot be blank.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} cannot be blank.');
$this->addError($object, $attribute, $message);
}
} else {
if (!$this->strict && $value != $this->requiredValue || $this->strict && $value !== $this->requiredValue) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} must be "{requiredValue}".');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} must be "{requiredValue}".');
$this->addError($object, $attribute, $message, array(
'{requiredValue}' => $this->requiredValue,
));
......@@ -71,7 +71,7 @@ class RequiredValidator extends Validator
$message = $this->message;
if ($this->requiredValue !== null) {
if ($message === null) {
$message = \Yii::t('yii:{attribute} must be "{requiredValue}".');
$message = \Yii::t('yii|{attribute} must be "{requiredValue}".');
}
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
......@@ -85,7 +85,7 @@ if (value != " . json_encode($this->requiredValue) . ") {
";
} else {
if ($message === null) {
$message = \Yii::t('yii:{attribute} cannot be blank.');
$message = \Yii::t('yii|{attribute} cannot be blank.');
}
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
......
......@@ -76,7 +76,7 @@ class StringValidator extends Validator
}
if (!is_string($value)) {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} must be a string.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} must be a string.');
$this->addError($object, $attribute, $message);
return;
}
......@@ -88,15 +88,15 @@ class StringValidator extends Validator
}
if ($this->min !== null && $length < $this->min) {
$message = ($this->tooShort !== null) ? $this->tooShort : \Yii::t('yii:{attribute} is too short (minimum is {min} characters).');
$message = ($this->tooShort !== null) ? $this->tooShort : \Yii::t('yii|{attribute} is too short (minimum is {min} characters).');
$this->addError($object, $attribute, $message, array('{min}' => $this->min));
}
if ($this->max !== null && $length > $this->max) {
$message = ($this->tooLong !== null) ? $this->tooLong : \Yii::t('yii:{attribute} is too long (maximum is {max} characters).');
$message = ($this->tooLong !== null) ? $this->tooLong : \Yii::t('yii|{attribute} is too long (maximum is {max} characters).');
$this->addError($object, $attribute, $message, array('{max}' => $this->max));
}
if ($this->is !== null && $length !== $this->is) {
$message = ($this->notEqual !== null) ? $this->notEqual : \Yii::t('yii:{attribute} is of the wrong length (should be {length} characters).');
$message = ($this->notEqual !== null) ? $this->notEqual : \Yii::t('yii|{attribute} is of the wrong length (should be {length} characters).');
$this->addError($object, $attribute, $message, array('{length}' => $this->is));
}
}
......@@ -113,7 +113,7 @@ class StringValidator extends Validator
$value = $object->$attribute;
if (($notEqual = $this->notEqual) === null) {
$notEqual = \Yii::t('yii:{attribute} is of the wrong length (should be {length} characters).');
$notEqual = \Yii::t('yii|{attribute} is of the wrong length (should be {length} characters).');
}
$notEqual = strtr($notEqual, array(
'{attribute}' => $label,
......@@ -122,7 +122,7 @@ class StringValidator extends Validator
));
if (($tooShort = $this->tooShort) === null) {
$tooShort = \Yii::t('yii:{attribute} is too short (minimum is {min} characters).');
$tooShort = \Yii::t('yii|{attribute} is too short (minimum is {min} characters).');
}
$tooShort = strtr($tooShort, array(
'{attribute}' => $label,
......@@ -131,7 +131,7 @@ class StringValidator extends Validator
));
if (($tooLong = $this->tooLong) === null) {
$tooLong = \Yii::t('yii:{attribute} is too long (maximum is {max} characters).');
$tooLong = \Yii::t('yii|{attribute} is too long (maximum is {max} characters).');
}
$tooLong = strtr($tooLong, array(
'{attribute}' => $label,
......
......@@ -86,7 +86,7 @@ class UniqueValidator extends Validator
}
if ($exists) {
$message = $this->message !== null ? $this->message : \Yii::t('yii:{attribute} "{value}" has already been taken.');
$message = $this->message !== null ? $this->message : \Yii::t('yii|{attribute} "{value}" has already been taken.');
$this->addError($object, $attribute, $message);
}
}
......
......@@ -55,7 +55,7 @@ class UrlValidator extends Validator
if (($value = $this->validateValue($value)) !== false) {
$object->$attribute = $value;
} else {
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is not a valid URL.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is not a valid URL.');
$this->addError($object, $attribute, $message);
}
}
......@@ -97,7 +97,7 @@ class UrlValidator extends Validator
*/
public function clientValidateAttribute($object, $attribute)
{
$message = ($this->message !== null) ? $this->message : \Yii::t('yii:{attribute} is not a valid URL.');
$message = ($this->message !== null) ? $this->message : \Yii::t('yii|{attribute} is not a valid URL.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
......
......@@ -113,7 +113,7 @@ class CAssetManager extends CApplicationComponent
if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
$this->_basePath=$basePath;
else
throw new CException(Yii::t('yii:CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
throw new CException(Yii::t('yii|CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
array('{path}'=>$value)));
}
......@@ -236,7 +236,7 @@ class CAssetManager extends CApplicationComponent
return $this->_published[$path]=$this->getBaseUrl().'/'.$dir;
}
}
throw new CException(Yii::t('yii:The asset "{asset}" to be published does not exist.',
throw new CException(Yii::t('yii|The asset "{asset}" to be published does not exist.',
array('{asset}'=>$path)));
}
......
......@@ -45,7 +45,7 @@ class Controller extends \yii\base\Controller
*/
public function invalidActionParams($action, $exception)
{
throw new HttpException(400, \Yii::t('yii:Your request is invalid.'));
throw new HttpException(400, \Yii::t('yii|Your request is invalid.'));
}
/**
......
......@@ -823,7 +823,7 @@ class Request extends \yii\base\Request
$valid = false;
}
if (!$valid) {
throw new CHttpException(400, Yii::t('yii:The CSRF token could not be verified.'));
throw new CHttpException(400, Yii::t('yii|The CSRF token could not be verified.'));
}
}
}
......
......@@ -115,7 +115,7 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar
@session_start();
if(YII_DEBUG && session_id()=='')
{
$message=Yii::t('yii:Failed to start session.');
$message=Yii::t('yii|Failed to start session.');
if(function_exists('error_get_last'))
{
$error=error_get_last();
......@@ -215,7 +215,7 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar
if(is_dir($value))
session_save_path($value);
else
throw new CException(Yii::t('yii:CHttpSession.savePath "{path}" is not a valid directory.',
throw new CException(Yii::t('yii|CHttpSession.savePath "{path}" is not a valid directory.',
array('{path}'=>$value)));
}
......@@ -280,7 +280,7 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar
ini_set('session.use_only_cookies','1');
}
else
throw new CException(Yii::t('yii:CHttpSession.cookieMode can only be "none", "allow" or "only".'));
throw new CException(Yii::t('yii|CHttpSession.cookieMode can only be "none", "allow" or "only".'));
}
/**
......@@ -304,7 +304,7 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar
ini_set('session.gc_divisor','100');
}
else
throw new CException(Yii::t('yii:CHttpSession.gcProbability "{value}" is invalid. It must be an integer between 0 and 100.',
throw new CException(Yii::t('yii|CHttpSession.gcProbability "{value}" is invalid. It must be an integer between 0 and 100.',
array('{value}'=>$value)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment