-1
這裏我user.php的延伸FOSUserBundle:Symfony2的驗證消息
class User extends AbstractUser
{
/**
* @var string
*
* @Assert\Email(
* message = "Please insert a valid email.",
* checkMX = true
* )
* @Assert\Regex(
* pattern="# #",
* match=false,
* message="Your mail can't contain spaces."
*)
* @Assert\NotBlank(groups={"step1", "step0", "edit"})
*
*/
protected $email;
/**
* @var string
*
* @ORM\Column(name="first_name", type="string", length=255, nullable=false)
* @Assert\NotBlank(groups={"step1", "edit"})
* @Assert\Regex(
* pattern="#(((\.|,|-|)?[0-9]){7}|hotmail|laposte|yopmail|wanadoo|gmail|yahoo|\.fr|\.co|\.it|\.be|\.de|\.es|\.nl|\.com|\.uk|\.at|\.au|\.ch|@)#",
* match=false,
* message="Warning: Be sure your ad does not contain an email address or phone number.")
* @Groups({"whitelabel", "mobile","full","large","small"})
*/
protected $firstName;
[...]
}
而且我validators.fr.xliff
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="52">
<source>Your mail can't contain spaces.</source>
<target>Votre mail ne peut pas contenir d'espaces.</target>
</trans-unit>
<trans-unit id="53">
<source>Please insert a valid email.</source>
<target>Merci d'insérer un email valide.</target>
</trans-unit>
<trans-unit id="100">
<source>Warning: Be sure your ad does not contain an email address or phone number.</source>
<target>Attention: Ce champ ne doit pas comporter d'adresse email ou numéro de téléphone.</target>
</trans-unit>
</body>
</file>
</xliff>
當我把郵件名字,錯誤信息被正確翻譯法文,但是當我放置空間或無效郵件時,錯誤消息是英文的。
任何人都知道爲什麼?
謝謝!
編輯:其他的東西可以幫助理解,當我把電子郵件驗證,如在文檔中,{{價值}}沒有與電子郵件轉換,我真的有「{{價值}}」在我的錯誤信息 - http://symfony.com/doc/current/reference/constraints/Email.html
/**
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* checkMX = true
*)
*/
protected $email;