How-to add constraint translation #1141

Merged
merged 1 commit into from Mar 21, 2012

Projects

None yet

3 participants

@azogheb
azogheb commented Mar 12, 2012

No description provided.

@stof stof commented on the diff Mar 12, 2012
book/translation.rst
+ use Symfony\Component\Validator\Mapping\ClassMetadata;
+ use Symfony\Component\Validator\Constraints\NotBlank;
+
+ class Author
+ {
+ public $name;
+
+ public static function loadValidatorMetadata(ClassMetadata $metadata)
+ {
+ $metadata->addPropertyConstraint('name', new NotBlank(array(
+ 'message' => 'author.name.not_blank'
+ )));
+ }
+ }
+
+Create a translation file under the ``validators`` catalog for the constraint messages, typically in the ``Resources/translations/`` directory of the bundle. See `Message Catalogues`_ for more details.
@stof
stof Mar 12, 2012 Member

please wrap lines after the first word crossing 72 chars

@weaverryan weaverryan merged commit d3170c4 into symfony:2.0 Mar 21, 2012
@weaverryan
Member

Hi Alexander!

Great PR - I've merged it in. Line lengths fixed at sha: 1e4d987

Big thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment