From e14cac638a227657ca85f9b343000f36f611f628 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 9 Jan 2014 02:26:56 +0400 Subject: [PATCH] Improved plural messages for validators --- framework/yii/validators/FileValidator.php | 6 +++--- framework/yii/validators/ImageValidator.php | 8 ++++---- framework/yii/validators/StringValidator.php | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/framework/yii/validators/FileValidator.php b/framework/yii/validators/FileValidator.php index 942bf1e..ac323e0 100644 --- a/framework/yii/validators/FileValidator.php +++ b/framework/yii/validators/FileValidator.php @@ -107,16 +107,16 @@ class FileValidator extends Validator $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, number} {limit, plural, one{file} other{files}}.'); } if ($this->wrongType === null) { $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, number} {limit, plural, one{byte} other{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, number} {limit, plural, one{byte} other{bytes}}.'); } if (!is_array($this->types)) { $this->types = preg_split('/[\s,]+/', strtolower($this->types), -1, PREG_SPLIT_NO_EMPTY); diff --git a/framework/yii/validators/ImageValidator.php b/framework/yii/validators/ImageValidator.php index b4ac1a8..d36002a 100644 --- a/framework/yii/validators/ImageValidator.php +++ b/framework/yii/validators/ImageValidator.php @@ -120,16 +120,16 @@ class ImageValidator extends FileValidator $this->notImage = Yii::t('yii', 'The file "{file}" is not an image.'); } if ($this->underWidth === null) { - $this->underWidth = Yii::t('yii', 'The file "{file}" is too small. The width cannot be smaller than {limit} pixels.'); + $this->underWidth = Yii::t('yii', 'The file "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); } if ($this->underHeight === null) { - $this->underHeight = Yii::t('yii', 'The file "{file}" is too small. The height cannot be smaller than {limit} pixels.'); + $this->underHeight = Yii::t('yii', 'The file "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); } if ($this->overWidth === null) { - $this->overWidth = Yii::t('yii', 'The file "{file}" is too large. The width cannot be larger than {limit} pixels.'); + $this->overWidth = Yii::t('yii', 'The file "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); } if ($this->overHeight === null) { - $this->overHeight = Yii::t('yii', 'The file "{file}" is too large. The height cannot be larger than {limit} pixels.'); + $this->overHeight = Yii::t('yii', 'The file "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); } if ($this->wrongMimeType === null) { $this->wrongMimeType = Yii::t('yii', 'Only files with these mimeTypes are allowed: {mimeTypes}.'); diff --git a/framework/yii/validators/StringValidator.php b/framework/yii/validators/StringValidator.php index 279a189..7d15aa7 100644 --- a/framework/yii/validators/StringValidator.php +++ b/framework/yii/validators/StringValidator.php @@ -84,13 +84,13 @@ class StringValidator extends Validator $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, number} {min, plural, one{character} other{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, number} {max, plural, one{character} other{characters}}.'); } if ($this->length !== null && $this->notEqual === null) { - $this->notEqual = Yii::t('yii', '{attribute} should contain {length} characters.'); + $this->notEqual = Yii::t('yii', '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.'); } }