Skip to content

Commit 85ee456

Browse files
committed
Translate constraint messages in Yaml file
1 parent f2c44f5 commit 85ee456

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
comment:
2+
blank: Please don't leave your comment blank!
3+
short: Comment is too short ({{ limit }} characters minimum)
4+
long: Comment is too long ({{ limit }} characters maximum)
5+
invalid: The content of this comment is considered spam.
6+
summary:
7+
blank: Give your post a summary!
8+
post:
9+
short: Post content is too short ({{ limit }} characters minimum)

src/AppBundle/Entity/Comment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class Comment
4343

4444
/**
4545
* @ORM\Column(type="text")
46-
* @Assert\NotBlank(message="Please don't leave your comment blank!")
46+
* @Assert\NotBlank(message="comment.blank")
4747
* @Assert\Length(
4848
* min = "5",
49-
* minMessage = "Comment is too short ({{ limit }} characters minimum)",
49+
* minMessage = "comment.short",
5050
* max = "10000",
51-
* maxMessage = "Comment is too long ({{ limit }} characters maximum)"
51+
* maxMessage = "comment.long"
5252
* )
5353
*/
5454
private $content;
@@ -71,7 +71,7 @@ public function __construct()
7171
}
7272

7373
/**
74-
* @Assert\IsTrue(message = "The content of this comment is considered spam.")
74+
* @Assert\IsTrue(message = "comment.invalid")
7575
*/
7676
public function isLegitComment()
7777
{

src/AppBundle/Entity/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ class Post
4747

4848
/**
4949
* @ORM\Column(type="string")
50-
* @Assert\NotBlank(message="Give your post a summary!")
50+
* @Assert\NotBlank(message="summary.blank")
5151
*/
5252
private $summary;
5353

5454
/**
5555
* @ORM\Column(type="text")
5656
* @Assert\Length(
5757
* min = "10",
58-
* minMessage = "Post content is too short ({{ limit }} characters minimum)"
58+
* minMessage = "post.short"
5959
* )
6060
*/
6161
private $content;

0 commit comments

Comments
 (0)