Commit e7fab51e by Alexander Makarov

fixes #1870: better fix that is message extractor friendly

parent cdfaf950
...@@ -72,11 +72,11 @@ class BooleanValidator extends Validator ...@@ -72,11 +72,11 @@ class BooleanValidator extends Validator
$options = [ $options = [
'trueValue' => $this->trueValue, 'trueValue' => $this->trueValue,
'falseValue' => $this->falseValue, 'falseValue' => $this->falseValue,
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
'true' => $this->trueValue, 'true' => $this->trueValue,
'false' => $this->falseValue, 'false' => $this->falseValue,
]), ], Yii::$app->language),
]; ];
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
......
...@@ -195,11 +195,11 @@ class CompareValidator extends Validator ...@@ -195,11 +195,11 @@ class CompareValidator extends Validator
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
} }
$options['message'] = Yii::t('yii', $this->message, [ $options['message'] = Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
'compareAttribute' => $compareValue, 'compareAttribute' => $compareValue,
'compareValue' => $compareValue, 'compareValue' => $compareValue,
]); ], Yii::$app->language);
ValidationAsset::register($view); ValidationAsset::register($view);
return 'yii.validation.compare(value, messages, ' . json_encode($options) . ');'; return 'yii.validation.compare(value, messages, ' . json_encode($options) . ');';
......
...@@ -98,9 +98,9 @@ class EmailValidator extends Validator ...@@ -98,9 +98,9 @@ class EmailValidator extends Validator
'pattern' => new JsExpression($this->pattern), 'pattern' => new JsExpression($this->pattern),
'fullPattern' => new JsExpression($this->fullPattern), 'fullPattern' => new JsExpression($this->fullPattern),
'allowName' => $this->allowName, 'allowName' => $this->allowName,
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
]), ], Yii::$app->language),
'enableIDN' => (boolean)$this->enableIDN, 'enableIDN' => (boolean)$this->enableIDN,
]; ];
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
......
...@@ -124,24 +124,24 @@ class NumberValidator extends Validator ...@@ -124,24 +124,24 @@ class NumberValidator extends Validator
$options = [ $options = [
'pattern' => new JsExpression($this->integerOnly ? $this->integerPattern : $this->numberPattern), 'pattern' => new JsExpression($this->integerOnly ? $this->integerPattern : $this->numberPattern),
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $label, 'attribute' => $label,
]), ], Yii::$app->language),
]; ];
if ($this->min !== null) { if ($this->min !== null) {
$options['min'] = $this->min; $options['min'] = $this->min;
$options['tooSmall'] = Yii::t('yii', $this->tooSmall, [ $options['tooSmall'] = Yii::$app->getI18n()->format($this->tooSmall, [
'attribute' => $label, 'attribute' => $label,
'min' => $this->min, 'min' => $this->min,
]); ], Yii::$app->language);
} }
if ($this->max !== null) { if ($this->max !== null) {
$options['max'] = $this->max; $options['max'] = $this->max;
$options['tooBig'] = Yii::t('yii', $this->tooBig, [ $options['tooBig'] = Yii::$app->getI18n()->format($this->tooBig, [
'attribute' => $label, 'attribute' => $label,
'max' => $this->max, 'max' => $this->max,
]); ], Yii::$app->language);
} }
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
......
...@@ -73,9 +73,9 @@ class RangeValidator extends Validator ...@@ -73,9 +73,9 @@ class RangeValidator extends Validator
$options = [ $options = [
'range' => $range, 'range' => $range,
'not' => $this->not, 'not' => $this->not,
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
]), ], Yii::$app->language),
]; ];
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
......
...@@ -80,9 +80,9 @@ class RegularExpressionValidator extends Validator ...@@ -80,9 +80,9 @@ class RegularExpressionValidator extends Validator
$options = [ $options = [
'pattern' => new JsExpression($pattern), 'pattern' => new JsExpression($pattern),
'not' => $this->not, 'not' => $this->not,
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
]), ], Yii::$app->language),
]; ];
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
......
...@@ -90,9 +90,9 @@ class RequiredValidator extends Validator ...@@ -90,9 +90,9 @@ class RequiredValidator extends Validator
{ {
$options = []; $options = [];
if ($this->requiredValue !== null) { if ($this->requiredValue !== null) {
$options['message'] = Yii::t('yii', $this->message, [ $options['message'] = Yii::$app->getI18n()->format($this->message, [
'requiredValue' => $this->requiredValue, 'requiredValue' => $this->requiredValue,
]); ], Yii::$app->language);
$options['requiredValue'] = $this->requiredValue; $options['requiredValue'] = $this->requiredValue;
} else { } else {
$options['message'] = $this->message; $options['message'] = $this->message;
...@@ -101,9 +101,9 @@ class RequiredValidator extends Validator ...@@ -101,9 +101,9 @@ class RequiredValidator extends Validator
$options['strict'] = 1; $options['strict'] = 1;
} }
$options['message'] = Yii::t('yii', $options['message'], [ $options['message'] = Yii::$app->getI18n()->format($options['message'], [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
]); ], Yii::$app->language);
ValidationAsset::register($view); ValidationAsset::register($view);
return 'yii.validation.required(value, messages, ' . json_encode($options) . ');'; return 'yii.validation.required(value, messages, ' . json_encode($options) . ');';
......
...@@ -151,31 +151,31 @@ class StringValidator extends Validator ...@@ -151,31 +151,31 @@ class StringValidator extends Validator
$label = $object->getAttributeLabel($attribute); $label = $object->getAttributeLabel($attribute);
$options = [ $options = [
'message' => Yii::t('yii', $this->message, [ 'message' => Yii::$app->getI18n()->format($this->message, [
'{attribute}' => $label, '{attribute}' => $label,
]), ], Yii::$app->language),
]; ];
if ($this->min !== null) { if ($this->min !== null) {
$options['min'] = $this->min; $options['min'] = $this->min;
$options['tooShort'] = Yii::t('yii', $this->tooShort, [ $options['tooShort'] = Yii::$app->getI18n()->format($this->tooShort, [
'attribute' => $label, 'attribute' => $label,
'min' => $this->min, 'min' => $this->min,
]); ], Yii::$app->language);
} }
if ($this->max !== null) { if ($this->max !== null) {
$options['max'] = $this->max; $options['max'] = $this->max;
$options['tooLong'] = Yii::t('yii', $this->tooLong, [ $options['tooLong'] = Yii::$app->getI18n()->format($this->tooLong, [
'attribute' => $label, 'attribute' => $label,
'max' => $this->max, 'max' => $this->max,
]); ], Yii::$app->language);
} }
if ($this->length !== null) { if ($this->length !== null) {
$options['is'] = $this->length; $options['is'] = $this->length;
$options['notEqual'] = Yii::t('yii', $this->notEqual, [ $options['notEqual'] = Yii::$app->getI18n()->format($this->notEqual, [
'attribute' => $label, 'attribute' => $label,
'length' => $this->length, 'length' => $this->length,
]); ], Yii::$app->language);
} }
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1; $options['skipOnEmpty'] = 1;
......
...@@ -121,9 +121,9 @@ class UrlValidator extends Validator ...@@ -121,9 +121,9 @@ class UrlValidator extends Validator
$options = [ $options = [
'pattern' => new JsExpression($pattern), 'pattern' => new JsExpression($pattern),
'message' => Yii::t('yii', $this->message, [ 'message' =>Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute), 'attribute' => $object->getAttributeLabel($attribute),
]), ], Yii::$app->language),
'enableIDN' => (boolean)$this->enableIDN, 'enableIDN' => (boolean)$this->enableIDN,
]; ];
if ($this->skipOnEmpty) { if ($this->skipOnEmpty) {
......
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