diff --git a/framework/validators/BooleanValidator.php b/framework/validators/BooleanValidator.php index 762a537ea0..95efd7b276 100644 --- a/framework/validators/BooleanValidator.php +++ b/framework/validators/BooleanValidator.php @@ -72,11 +72,11 @@ class BooleanValidator extends Validator $options = [ 'trueValue' => $this->trueValue, 'falseValue' => $this->falseValue, - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), 'true' => $this->trueValue, 'false' => $this->falseValue, - ]), + ], Yii::$app->language), ]; if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/framework/validators/CompareValidator.php b/framework/validators/CompareValidator.php index be9b646b93..c0e67df0a8 100644 --- a/framework/validators/CompareValidator.php +++ b/framework/validators/CompareValidator.php @@ -195,11 +195,11 @@ class CompareValidator extends Validator $options['skipOnEmpty'] = 1; } - $options['message'] = Yii::t('yii', $this->message, [ + $options['message'] = Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), 'compareAttribute' => $compareValue, 'compareValue' => $compareValue, - ]); + ], Yii::$app->language); ValidationAsset::register($view); return 'yii.validation.compare(value, messages, ' . json_encode($options) . ');'; diff --git a/framework/validators/EmailValidator.php b/framework/validators/EmailValidator.php index d2a7a232ad..2ca87b6c91 100644 --- a/framework/validators/EmailValidator.php +++ b/framework/validators/EmailValidator.php @@ -98,9 +98,9 @@ class EmailValidator extends Validator 'pattern' => new JsExpression($this->pattern), 'fullPattern' => new JsExpression($this->fullPattern), 'allowName' => $this->allowName, - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), - ]), + ], Yii::$app->language), 'enableIDN' => (boolean)$this->enableIDN, ]; if ($this->skipOnEmpty) { diff --git a/framework/validators/NumberValidator.php b/framework/validators/NumberValidator.php index 4f45b21678..386f9d8ebc 100644 --- a/framework/validators/NumberValidator.php +++ b/framework/validators/NumberValidator.php @@ -124,24 +124,24 @@ class NumberValidator extends Validator $options = [ 'pattern' => new JsExpression($this->integerOnly ? $this->integerPattern : $this->numberPattern), - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ 'attribute' => $label, - ]), + ], Yii::$app->language), ]; if ($this->min !== null) { $options['min'] = $this->min; - $options['tooSmall'] = Yii::t('yii', $this->tooSmall, [ + $options['tooSmall'] = Yii::$app->getI18n()->format($this->tooSmall, [ 'attribute' => $label, 'min' => $this->min, - ]); + ], Yii::$app->language); } if ($this->max !== null) { $options['max'] = $this->max; - $options['tooBig'] = Yii::t('yii', $this->tooBig, [ + $options['tooBig'] = Yii::$app->getI18n()->format($this->tooBig, [ 'attribute' => $label, 'max' => $this->max, - ]); + ], Yii::$app->language); } if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/framework/validators/RangeValidator.php b/framework/validators/RangeValidator.php index c8694da340..0b84afac7d 100644 --- a/framework/validators/RangeValidator.php +++ b/framework/validators/RangeValidator.php @@ -73,9 +73,9 @@ class RangeValidator extends Validator $options = [ 'range' => $range, 'not' => $this->not, - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), - ]), + ], Yii::$app->language), ]; if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/framework/validators/RegularExpressionValidator.php b/framework/validators/RegularExpressionValidator.php index 6e5011b3f7..a1ca389c86 100644 --- a/framework/validators/RegularExpressionValidator.php +++ b/framework/validators/RegularExpressionValidator.php @@ -80,9 +80,9 @@ class RegularExpressionValidator extends Validator $options = [ 'pattern' => new JsExpression($pattern), 'not' => $this->not, - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), - ]), + ], Yii::$app->language), ]; if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/framework/validators/RequiredValidator.php b/framework/validators/RequiredValidator.php index c0e1ed96f9..66b810947e 100644 --- a/framework/validators/RequiredValidator.php +++ b/framework/validators/RequiredValidator.php @@ -90,9 +90,9 @@ class RequiredValidator extends Validator { $options = []; if ($this->requiredValue !== null) { - $options['message'] = Yii::t('yii', $this->message, [ + $options['message'] = Yii::$app->getI18n()->format($this->message, [ 'requiredValue' => $this->requiredValue, - ]); + ], Yii::$app->language); $options['requiredValue'] = $this->requiredValue; } else { $options['message'] = $this->message; @@ -101,9 +101,9 @@ class RequiredValidator extends Validator $options['strict'] = 1; } - $options['message'] = Yii::t('yii', $options['message'], [ + $options['message'] = Yii::$app->getI18n()->format($options['message'], [ 'attribute' => $object->getAttributeLabel($attribute), - ]); + ], Yii::$app->language); ValidationAsset::register($view); return 'yii.validation.required(value, messages, ' . json_encode($options) . ');'; diff --git a/framework/validators/StringValidator.php b/framework/validators/StringValidator.php index e28ae1d2a2..5669f93f03 100644 --- a/framework/validators/StringValidator.php +++ b/framework/validators/StringValidator.php @@ -151,31 +151,31 @@ class StringValidator extends Validator $label = $object->getAttributeLabel($attribute); $options = [ - 'message' => Yii::t('yii', $this->message, [ + 'message' => Yii::$app->getI18n()->format($this->message, [ '{attribute}' => $label, - ]), + ], Yii::$app->language), ]; if ($this->min !== null) { $options['min'] = $this->min; - $options['tooShort'] = Yii::t('yii', $this->tooShort, [ + $options['tooShort'] = Yii::$app->getI18n()->format($this->tooShort, [ 'attribute' => $label, 'min' => $this->min, - ]); + ], Yii::$app->language); } if ($this->max !== null) { $options['max'] = $this->max; - $options['tooLong'] = Yii::t('yii', $this->tooLong, [ + $options['tooLong'] = Yii::$app->getI18n()->format($this->tooLong, [ 'attribute' => $label, 'max' => $this->max, - ]); + ], Yii::$app->language); } if ($this->length !== null) { $options['is'] = $this->length; - $options['notEqual'] = Yii::t('yii', $this->notEqual, [ + $options['notEqual'] = Yii::$app->getI18n()->format($this->notEqual, [ 'attribute' => $label, 'length' => $this->length, - ]); + ], Yii::$app->language); } if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/framework/validators/UrlValidator.php b/framework/validators/UrlValidator.php index a60640a9c8..f91e1065b4 100644 --- a/framework/validators/UrlValidator.php +++ b/framework/validators/UrlValidator.php @@ -121,9 +121,9 @@ class UrlValidator extends Validator $options = [ 'pattern' => new JsExpression($pattern), - 'message' => Yii::t('yii', $this->message, [ + 'message' =>Yii::$app->getI18n()->format($this->message, [ 'attribute' => $object->getAttributeLabel($attribute), - ]), + ], Yii::$app->language), 'enableIDN' => (boolean)$this->enableIDN, ]; if ($this->skipOnEmpty) {