diff --git a/docs/guide/upgrade-from-v1.md b/docs/guide/upgrade-from-v1.md index c89b3e8..50e6977 100644 --- a/docs/guide/upgrade-from-v1.md +++ b/docs/guide/upgrade-from-v1.md @@ -269,10 +269,6 @@ Message translation is still supported, but managed via the "i18n" application c The component manages a set of message sources, which allows you to use different message sources based on message categories. For more information, see the class documentation for `I18N`. -The message translation method is changed by merging the message category into the message being -translated. For example, `Yii::t('yii|message to be translated')`. - - Action Filters -------------- diff --git a/yii/YiiBase.php b/yii/YiiBase.php index 1a3f50c..ce421d4 100644 --- a/yii/YiiBase.php +++ b/yii/YiiBase.php @@ -579,10 +579,9 @@ class YiiBase /** * Translates a message to the specified language. * - * The translation will be conducted according to the message category and the target language. - * To specify the category of the message, prefix the message with the category name and separate it - * with "|". For example, "app|hello world". If the category is not specified, the default category "app" - * will be used. The actual message translation is done by a [[\yii\i18n\MessageSource|message source]]. + * This is a shortcut method of [[\yii\i18n\I18N::translate()]]. + * + * The translation will be conducted according to the message category and the target language will be used. * * In case when a translated message has different plural forms (separated by "|"), this method * will also attempt to choose an appropriate one according to a given numeric value which is @@ -595,20 +594,18 @@ class YiiBase * For more details on how plural rules are applied, please refer to: * [[http://www.unicode.org/cldr/charts/supplemental/language_plural_rules.html]] * + * @param string $category the message category. * @param string $message the message to be translated. * @param array $params the parameters that will be used to replace the corresponding placeholders in the message. * @param string $language the language code (e.g. `en_US`, `en`). If this is null, the current * [[\yii\base\Application::language|application language]] will be used. * @return string the translated message. */ - public static function t($message, $params = array(), $language = null) + public static function t($category, $message, $params = array(), $language = null) { if (self::$app !== null) { - return self::$app->getI18N()->translate($message, $params, $language); + return self::$app->getI18N()->translate($category, $message, $params, $language); } else { - if (strpos($message, '|') !== false && preg_match('/^([\w\-\\/\.\\\\]+)\|(.*)/', $message, $matches)) { - $message = $matches[2]; - } return is_array($params) ? strtr($message, $params) : $message; } } diff --git a/yii/base/Controller.php b/yii/base/Controller.php index 55db4ed..0639e2b 100644 --- a/yii/base/Controller.php +++ b/yii/base/Controller.php @@ -183,7 +183,7 @@ class Controller extends Component } if (!empty($missing)) { - 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), ))); } diff --git a/yii/base/ErrorException.php b/yii/base/ErrorException.php index b41e9ed..8e1977a 100644 --- a/yii/base/ErrorException.php +++ b/yii/base/ErrorException.php @@ -90,20 +90,20 @@ class ErrorException extends Exception public function getName() { $names = array( - E_ERROR => Yii::t('yii|Fatal Error'), - E_PARSE => Yii::t('yii|Parse Error'), - E_CORE_ERROR => Yii::t('yii|Core Error'), - E_COMPILE_ERROR => Yii::t('yii|Compile Error'), - E_USER_ERROR => Yii::t('yii|User Error'), - E_WARNING => Yii::t('yii|Warning'), - E_CORE_WARNING => Yii::t('yii|Core Warning'), - E_COMPILE_WARNING => Yii::t('yii|Compile Warning'), - E_USER_WARNING => Yii::t('yii|User Warning'), - E_STRICT => Yii::t('yii|Strict'), - E_NOTICE => Yii::t('yii|Notice'), - E_RECOVERABLE_ERROR => Yii::t('yii|Recoverable Error'), - E_DEPRECATED => Yii::t('yii|Deprecated'), + E_ERROR => Yii::t('yii', 'Fatal Error'), + E_PARSE => Yii::t('yii', 'Parse Error'), + E_CORE_ERROR => Yii::t('yii', 'Core Error'), + E_COMPILE_ERROR => Yii::t('yii', 'Compile Error'), + E_USER_ERROR => Yii::t('yii', 'User Error'), + E_WARNING => Yii::t('yii', 'Warning'), + E_CORE_WARNING => Yii::t('yii', 'Core Warning'), + E_COMPILE_WARNING => Yii::t('yii', 'Compile Warning'), + E_USER_WARNING => Yii::t('yii', 'User Warning'), + E_STRICT => Yii::t('yii', 'Strict'), + E_NOTICE => Yii::t('yii', 'Notice'), + E_RECOVERABLE_ERROR => Yii::t('yii', 'Recoverable Error'), + E_DEPRECATED => Yii::t('yii', 'Deprecated'), ); - return isset($names[$this->getCode()]) ? $names[$this->getCode()] : Yii::t('yii|Error'); + return isset($names[$this->getCode()]) ? $names[$this->getCode()] : Yii::t('yii', 'Error'); } } diff --git a/yii/base/Exception.php b/yii/base/Exception.php index 7d26bd0..956f17b 100644 --- a/yii/base/Exception.php +++ b/yii/base/Exception.php @@ -20,6 +20,6 @@ class Exception extends \Exception */ public function getName() { - return \Yii::t('yii|Exception'); + return \Yii::t('yii', 'Exception'); } } diff --git a/yii/base/HttpException.php b/yii/base/HttpException.php index 55e0531..2b014f7 100644 --- a/yii/base/HttpException.php +++ b/yii/base/HttpException.php @@ -103,7 +103,7 @@ class HttpException extends UserException if (isset($httpCodes[$this->statusCode])) { return $httpCodes[$this->statusCode]; } else { - return \Yii::t('yii|Error'); + return \Yii::t('yii', 'Error'); } } } diff --git a/yii/base/InvalidCallException.php b/yii/base/InvalidCallException.php index 9aefe14..9a146d4 100644 --- a/yii/base/InvalidCallException.php +++ b/yii/base/InvalidCallException.php @@ -20,7 +20,7 @@ class InvalidCallException extends Exception */ public function getName() { - return \Yii::t('yii|Invalid Call'); + return \Yii::t('yii', 'Invalid Call'); } } diff --git a/yii/base/InvalidConfigException.php b/yii/base/InvalidConfigException.php index 389737c..c617381 100644 --- a/yii/base/InvalidConfigException.php +++ b/yii/base/InvalidConfigException.php @@ -20,7 +20,7 @@ class InvalidConfigException extends Exception */ public function getName() { - return \Yii::t('yii|Invalid Configuration'); + return \Yii::t('yii', 'Invalid Configuration'); } } diff --git a/yii/base/InvalidParamException.php b/yii/base/InvalidParamException.php index a8c96fd..0262051 100644 --- a/yii/base/InvalidParamException.php +++ b/yii/base/InvalidParamException.php @@ -20,7 +20,7 @@ class InvalidParamException extends Exception */ public function getName() { - return \Yii::t('yii|Invalid Parameter'); + return \Yii::t('yii', 'Invalid Parameter'); } } diff --git a/yii/base/InvalidRequestException.php b/yii/base/InvalidRequestException.php index 6663e29..f4806ce 100644 --- a/yii/base/InvalidRequestException.php +++ b/yii/base/InvalidRequestException.php @@ -20,7 +20,7 @@ class InvalidRequestException extends UserException */ public function getName() { - return \Yii::t('yii|Invalid Request'); + return \Yii::t('yii', 'Invalid Request'); } } diff --git a/yii/base/InvalidRouteException.php b/yii/base/InvalidRouteException.php index 6d2256e..a573636 100644 --- a/yii/base/InvalidRouteException.php +++ b/yii/base/InvalidRouteException.php @@ -20,7 +20,7 @@ class InvalidRouteException extends UserException */ public function getName() { - return \Yii::t('yii|Invalid Route'); + return \Yii::t('yii', 'Invalid Route'); } } diff --git a/yii/base/NotSupportedException.php b/yii/base/NotSupportedException.php index 2f08891..8a93e14 100644 --- a/yii/base/NotSupportedException.php +++ b/yii/base/NotSupportedException.php @@ -20,7 +20,7 @@ class NotSupportedException extends Exception */ public function getName() { - return \Yii::t('yii|Not Supported'); + return \Yii::t('yii', 'Not Supported'); } } diff --git a/yii/base/UnknownClassException.php b/yii/base/UnknownClassException.php index ac44746..e4a682a 100644 --- a/yii/base/UnknownClassException.php +++ b/yii/base/UnknownClassException.php @@ -20,7 +20,7 @@ class UnknownClassException extends Exception */ public function getName() { - return \Yii::t('yii|Unknown Class'); + return \Yii::t('yii', 'Unknown Class'); } } diff --git a/yii/base/UnknownMethodException.php b/yii/base/UnknownMethodException.php index 440e76e..d8cea34 100644 --- a/yii/base/UnknownMethodException.php +++ b/yii/base/UnknownMethodException.php @@ -20,7 +20,7 @@ class UnknownMethodException extends Exception */ public function getName() { - return \Yii::t('yii|Unknown Method'); + return \Yii::t('yii', 'Unknown Method'); } } diff --git a/yii/base/UnknownPropertyException.php b/yii/base/UnknownPropertyException.php index 5ec3814..b8e93c5 100644 --- a/yii/base/UnknownPropertyException.php +++ b/yii/base/UnknownPropertyException.php @@ -20,7 +20,7 @@ class UnknownPropertyException extends Exception */ public function getName() { - return \Yii::t('yii|Unknown Property'); + return \Yii::t('yii', 'Unknown Property'); } } diff --git a/yii/console/Application.php b/yii/console/Application.php index 2f28cac..51506fe 100644 --- a/yii/console/Application.php +++ b/yii/console/Application.php @@ -94,7 +94,7 @@ class Application extends \yii\base\Application list ($route, $params) = $request->resolve(); return $this->runAction($route, $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.')); } } @@ -113,7 +113,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))); } } diff --git a/yii/console/Controller.php b/yii/console/Controller.php index c07d92d..7d71896 100644 --- a/yii/console/Controller.php +++ b/yii/console/Controller.php @@ -91,7 +91,7 @@ class Controller extends \yii\base\Controller $args = isset($params[Request::ANONYMOUS_PARAMS]) ? $params[Request::ANONYMOUS_PARAMS] : array(); unset($params[Request::ANONYMOUS_PARAMS]); if (!empty($params)) { - 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)), ))); } @@ -115,7 +115,7 @@ class Controller extends \yii\base\Controller } if (!empty($missing)) { - 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), ))); } diff --git a/yii/console/Exception.php b/yii/console/Exception.php index cb10c19..9e9003e 100644 --- a/yii/console/Exception.php +++ b/yii/console/Exception.php @@ -22,7 +22,7 @@ class Exception extends UserException */ public function getName() { - return \Yii::t('yii|Error'); + return \Yii::t('yii', 'Error'); } } diff --git a/yii/console/controllers/HelpController.php b/yii/console/controllers/HelpController.php index 6a66fd0..898a1e7 100644 --- a/yii/console/controllers/HelpController.php +++ b/yii/console/controllers/HelpController.php @@ -55,7 +55,7 @@ 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}".', array( + throw new Exception(Yii::t('yii', 'No help for unknown command "{command}".', array( '{command}' => $command, ))); } @@ -239,7 +239,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, '/'), ))); } diff --git a/yii/db/Exception.php b/yii/db/Exception.php index b7a60b4..9339211 100644 --- a/yii/db/Exception.php +++ b/yii/db/Exception.php @@ -39,6 +39,6 @@ class Exception extends \yii\base\Exception */ public function getName() { - return \Yii::t('yii|Database Exception'); + return \Yii::t('yii', 'Database Exception'); } } diff --git a/yii/db/StaleObjectException.php b/yii/db/StaleObjectException.php index 0a04bd3..dc88ceb 100644 --- a/yii/db/StaleObjectException.php +++ b/yii/db/StaleObjectException.php @@ -18,6 +18,6 @@ class StaleObjectException extends Exception */ public function getName() { - return \Yii::t('yii|Stale Object Exception'); + return \Yii::t('yii', 'Stale Object Exception'); } } diff --git a/yii/i18n/I18N.php b/yii/i18n/I18N.php index 1477fd4..a358683 100644 --- a/yii/i18n/I18N.php +++ b/yii/i18n/I18N.php @@ -75,26 +75,19 @@ class I18N extends Component * Translates a message to the specified language. * If the first parameter in `$params` is a number and it is indexed by 0, appropriate plural rules * will be applied to the translated message. + * @param string $category the message category. * @param string $message the message to be translated. * @param array $params the parameters that will be used to replace the corresponding placeholders in the message. * @param string $language the language code (e.g. `en_US`, `en`). If this is null, the current * [[\yii\base\Application::language|application language]] will be used. * @return string the translated message. */ - public function translate($message, $params = array(), $language = null) + public function translate($category, $message, $params = array(), $language = null) { if ($language === null) { $language = Yii::$app->language; } - // allow chars for category: word chars, ".", "-", "/", "\" - if (strpos($message, '|') !== false && preg_match('/^([\w\-\\/\.\\\\]+)\|(.*)/', $message, $matches)) { - $category = $matches[1]; - $message = $matches[2]; - } else { - $category = 'app'; - } - $message = $this->getMessageSource($category)->translate($category, $message, $language); if (!is_array($params)) { diff --git a/yii/logging/EmailTarget.php b/yii/logging/EmailTarget.php index bb02e34..94e2c00 100644 --- a/yii/logging/EmailTarget.php +++ b/yii/logging/EmailTarget.php @@ -48,7 +48,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); } diff --git a/yii/logging/ProfileTarget.php b/yii/logging/ProfileTarget.php index 75447c9..f4522ac 100644 --- a/yii/logging/ProfileTarget.php +++ b/yii/logging/ProfileTarget.php @@ -59,7 +59,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))); } @@ -106,7 +106,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))); } } @@ -149,7 +149,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))); } } diff --git a/yii/validators/BooleanValidator.php b/yii/validators/BooleanValidator.php index 1420739..2929dfd 100644 --- a/yii/validators/BooleanValidator.php +++ b/yii/validators/BooleanValidator.php @@ -43,7 +43,7 @@ class BooleanValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} must be either "{true}" or "{false}".'); + $this->message = Yii::t('yii', '{attribute} must be either "{true}" or "{false}".'); } } diff --git a/yii/validators/CaptchaValidator.php b/yii/validators/CaptchaValidator.php index 2e58cf2..c49ffdb 100644 --- a/yii/validators/CaptchaValidator.php +++ b/yii/validators/CaptchaValidator.php @@ -39,7 +39,7 @@ class CaptchaValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|The verification code is incorrect.'); + $this->message = Yii::t('yii', 'The verification code is incorrect.'); } } diff --git a/yii/validators/CompareValidator.php b/yii/validators/CompareValidator.php index 68504e5..7f7318f 100644 --- a/yii/validators/CompareValidator.php +++ b/yii/validators/CompareValidator.php @@ -79,28 +79,28 @@ class CompareValidator extends Validator if ($this->message === null) { switch ($this->operator) { case '==': - $this->message = Yii::t('yii|{attribute} must be repeated exactly.'); + $this->message = Yii::t('yii', '{attribute} must be repeated exactly.'); break; case '===': - $this->message = Yii::t('yii|{attribute} must be repeated exactly.'); + $this->message = Yii::t('yii', '{attribute} must be repeated exactly.'); break; case '!=': - $this->message = Yii::t('yii|{attribute} must not be equal to "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must not be equal to "{compareValue}".'); break; case '!==': - $this->message = Yii::t('yii|{attribute} must not be equal to "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must not be equal to "{compareValue}".'); break; case '>': - $this->message = Yii::t('yii|{attribute} must be greater than "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must be greater than "{compareValue}".'); break; case '>=': - $this->message = Yii::t('yii|{attribute} must be greater than or equal to "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must be greater than or equal to "{compareValue}".'); break; case '<': - $this->message = Yii::t('yii|{attribute} must be less than "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must be less than "{compareValue}".'); break; case '<=': - $this->message = Yii::t('yii|{attribute} must be less than or equal to "{compareValue}".'); + $this->message = Yii::t('yii', '{attribute} must be less than or equal to "{compareValue}".'); break; default: throw new InvalidConfigException("Unknown operator: {$this->operator}"); @@ -119,7 +119,7 @@ class CompareValidator extends Validator { $value = $object->$attribute; if (is_array($value)) { - $this->addError($object, $attribute, Yii::t('yii|{attribute} is invalid.')); + $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.')); return; } if ($this->compareValue !== null) { diff --git a/yii/validators/DateValidator.php b/yii/validators/DateValidator.php index 7c3b181..7370b78 100644 --- a/yii/validators/DateValidator.php +++ b/yii/validators/DateValidator.php @@ -38,7 +38,7 @@ class DateValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|The format of {attribute} is invalid.'); + $this->message = Yii::t('yii', 'The format of {attribute} is invalid.'); } } diff --git a/yii/validators/EmailValidator.php b/yii/validators/EmailValidator.php index 949b3f9..dce6c37 100644 --- a/yii/validators/EmailValidator.php +++ b/yii/validators/EmailValidator.php @@ -55,7 +55,7 @@ class EmailValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} is not a valid email address.'); + $this->message = Yii::t('yii', '{attribute} is not a valid email address.'); } } diff --git a/yii/validators/ExistValidator.php b/yii/validators/ExistValidator.php index 7aa434c..7c45491 100644 --- a/yii/validators/ExistValidator.php +++ b/yii/validators/ExistValidator.php @@ -45,7 +45,7 @@ class ExistValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} is invalid.'); + $this->message = Yii::t('yii', '{attribute} is invalid.'); } } diff --git a/yii/validators/FileValidator.php b/yii/validators/FileValidator.php index cc36d07..8a3ab9e 100644 --- a/yii/validators/FileValidator.php +++ b/yii/validators/FileValidator.php @@ -97,22 +97,22 @@ class FileValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|File upload failed.'); + $this->message = Yii::t('yii', 'File upload failed.'); } if ($this->uploadRequired === null) { - $this->uploadRequired = Yii::t('yii|Please upload a file.'); + $this->uploadRequired = Yii::t('yii', 'Please upload a file.'); } if ($this->tooMany === null) { - $this->tooMany = Yii::t('yii|You can upload at most {limit} files.'); + $this->tooMany = Yii::t('yii', 'You can upload at most {limit} files.'); } if ($this->wrongType === null) { - $this->wrongType = Yii::t('yii|Only files with these extensions are allowed: {extensions}.'); + $this->wrongType = Yii::t('yii', 'Only files with these extensions are allowed: {extensions}.'); } if ($this->tooBig === null) { - $this->tooBig = Yii::t('yii|The file "{file}" is too big. Its size cannot exceed {limit} bytes.'); + $this->tooBig = Yii::t('yii', 'The file "{file}" is too big. Its size cannot exceed {limit} bytes.'); } if ($this->tooSmall === null) { - $this->tooSmall = Yii::t('yii|The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.'); + $this->tooSmall = Yii::t('yii', 'The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.'); } if (!is_array($this->types)) { $this->types = preg_split('/[\s,]+/', strtolower($this->types), -1, PREG_SPLIT_NO_EMPTY); diff --git a/yii/validators/NumberValidator.php b/yii/validators/NumberValidator.php index 10f0e52..33822bf 100644 --- a/yii/validators/NumberValidator.php +++ b/yii/validators/NumberValidator.php @@ -62,14 +62,14 @@ class NumberValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = $this->integerOnly ? Yii::t('yii|{attribute} must be an integer.') - : Yii::t('yii|{attribute} must be a number.'); + $this->message = $this->integerOnly ? Yii::t('yii', '{attribute} must be an integer.') + : Yii::t('yii', '{attribute} must be a number.'); } if ($this->min !== null && $this->tooSmall === null) { - $this->tooSmall = Yii::t('yii|{attribute} must be no less than {min}.'); + $this->tooSmall = Yii::t('yii', '{attribute} must be no less than {min}.'); } if ($this->max !== null && $this->tooBig === null) { - $this->tooBig = Yii::t('yii|{attribute} must be no greater than {max}.'); + $this->tooBig = Yii::t('yii', '{attribute} must be no greater than {max}.'); } } @@ -83,7 +83,7 @@ class NumberValidator extends Validator { $value = $object->$attribute; if (is_array($value)) { - $this->addError($object, $attribute, Yii::t('yii|{attribute} is invalid.')); + $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.')); return; } $pattern = $this->integerOnly ? $this->integerPattern : $this->numberPattern; diff --git a/yii/validators/RangeValidator.php b/yii/validators/RangeValidator.php index 2a9e15f..4bed303 100644 --- a/yii/validators/RangeValidator.php +++ b/yii/validators/RangeValidator.php @@ -48,7 +48,7 @@ class RangeValidator extends Validator throw new InvalidConfigException('The "range" property must be set.'); } if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} is invalid.'); + $this->message = Yii::t('yii', '{attribute} is invalid.'); } } diff --git a/yii/validators/RegularExpressionValidator.php b/yii/validators/RegularExpressionValidator.php index 23419b9..505812f 100644 --- a/yii/validators/RegularExpressionValidator.php +++ b/yii/validators/RegularExpressionValidator.php @@ -45,7 +45,7 @@ class RegularExpressionValidator extends Validator throw new InvalidConfigException('The "pattern" property must be set.'); } if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} is invalid.'); + $this->message = Yii::t('yii', '{attribute} is invalid.'); } } diff --git a/yii/validators/RequiredValidator.php b/yii/validators/RequiredValidator.php index 4c14a8d..424f94c 100644 --- a/yii/validators/RequiredValidator.php +++ b/yii/validators/RequiredValidator.php @@ -57,8 +57,8 @@ class RequiredValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = $this->requiredValue === null ? Yii::t('yii|{attribute} cannot be blank.') - : Yii::t('yii|{attribute} must be "{requiredValue}".'); + $this->message = $this->requiredValue === null ? Yii::t('yii', '{attribute} cannot be blank.') + : Yii::t('yii', '{attribute} must be "{requiredValue}".'); } } diff --git a/yii/validators/StringValidator.php b/yii/validators/StringValidator.php index 5d0fa1a..110619e 100644 --- a/yii/validators/StringValidator.php +++ b/yii/validators/StringValidator.php @@ -65,16 +65,16 @@ class StringValidator extends Validator $this->encoding = Yii::$app->charset; } if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} must be a string.'); + $this->message = Yii::t('yii', '{attribute} must be a string.'); } if ($this->min !== null && $this->tooShort === null) { - $this->tooShort = Yii::t('yii|{attribute} should contain at least {min} characters.'); + $this->tooShort = Yii::t('yii', '{attribute} should contain at least {min} characters.'); } if ($this->max !== null && $this->tooLong === null) { - $this->tooLong = Yii::t('yii|{attribute} should contain at most {max} characters.'); + $this->tooLong = Yii::t('yii', '{attribute} should contain at most {max} characters.'); } if ($this->is !== null && $this->notEqual === null) { - $this->notEqual = Yii::t('yii|{attribute} should contain {length} characters.'); + $this->notEqual = Yii::t('yii', '{attribute} should contain {length} characters.'); } } diff --git a/yii/validators/UniqueValidator.php b/yii/validators/UniqueValidator.php index 7072ff4..a4d8bff 100644 --- a/yii/validators/UniqueValidator.php +++ b/yii/validators/UniqueValidator.php @@ -39,7 +39,7 @@ class UniqueValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} "{value}" has already been taken.'); + $this->message = Yii::t('yii', '{attribute} "{value}" has already been taken.'); } } @@ -55,7 +55,7 @@ class UniqueValidator extends Validator $value = $object->$attribute; if (is_array($value)) { - $this->addError($object, $attribute, Yii::t('yii|{attribute} is invalid.')); + $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.')); return; } diff --git a/yii/validators/UrlValidator.php b/yii/validators/UrlValidator.php index c418353..6917d01 100644 --- a/yii/validators/UrlValidator.php +++ b/yii/validators/UrlValidator.php @@ -46,7 +46,7 @@ class UrlValidator extends Validator { parent::init(); if ($this->message === null) { - $this->message = Yii::t('yii|{attribute} is not a valid URL.'); + $this->message = Yii::t('yii', '{attribute} is not a valid URL.'); } } diff --git a/yii/web/AccessControl.php b/yii/web/AccessControl.php index e890510..c4efd19 100644 --- a/yii/web/AccessControl.php +++ b/yii/web/AccessControl.php @@ -100,7 +100,7 @@ class AccessControl extends ActionFilter if ($user->getIsGuest()) { $user->loginRequired(); } else { - throw new HttpException(403, Yii::t('yii|You are not allowed to perform this action.')); + throw new HttpException(403, Yii::t('yii', 'You are not allowed to perform this action.')); } } } diff --git a/yii/web/Request.php b/yii/web/Request.php index d3f419b..2f4568a 100644 --- a/yii/web/Request.php +++ b/yii/web/Request.php @@ -72,7 +72,7 @@ class Request extends \yii\base\Request $_GET = array_merge($_GET, $params); return array($route, $_GET); } else { - throw new HttpException(404, Yii::t('yii|Page not found.')); + throw new HttpException(404, Yii::t('yii', 'Page not found.')); } } @@ -786,7 +786,7 @@ class Request extends \yii\base\Request } if (empty($token) || $cookies->getValue($this->csrfTokenName) !== $token) { - throw new HttpException(400, Yii::t('yii|Unable to verify your data submission.')); + throw new HttpException(400, Yii::t('yii', 'Unable to verify your data submission.')); } } } diff --git a/yii/web/User.php b/yii/web/User.php index 7d8e300..79665ae 100644 --- a/yii/web/User.php +++ b/yii/web/User.php @@ -286,7 +286,7 @@ class User extends Component if ($this->loginUrl !== null) { Yii::$app->getResponse()->redirect($this->loginUrl); } else { - throw new HttpException(403, Yii::t('yii|Login Required')); + throw new HttpException(403, Yii::t('yii', 'Login Required')); } } diff --git a/yii/widgets/ActiveForm.php b/yii/widgets/ActiveForm.php index 24451b9..25a2054 100644 --- a/yii/widgets/ActiveForm.php +++ b/yii/widgets/ActiveForm.php @@ -187,7 +187,7 @@ class ActiveForm extends Widget } } - $header = isset($options['header']) ? $options['header'] : '

' . Yii::t('yii|Please fix the following errors:') . '

'; + $header = isset($options['header']) ? $options['header'] : '

' . Yii::t('yii', 'Please fix the following errors:') . '

'; $footer = isset($options['footer']) ? $options['footer'] : ''; unset($options['header'], $options['footer']); diff --git a/yii/widgets/Breadcrumbs.php b/yii/widgets/Breadcrumbs.php index 5d15689..9214f86 100644 --- a/yii/widgets/Breadcrumbs.php +++ b/yii/widgets/Breadcrumbs.php @@ -103,7 +103,7 @@ class Breadcrumbs extends Widget $links = array(); if ($this->homeLink === null) { $links[] = $this->renderItem(array( - 'label' => Yii::t('yii|Home'), + 'label' => Yii::t('yii', 'Home'), 'url' => Yii::$app->homeUrl, ), $this->itemTemplate); } elseif ($this->homeLink !== false) {