Php 如何添加包含Doctrine@Uniquentity约束内部链接的Symfony2翻译?
我试图在我的条令映射中的@uniquentity消息中添加一个链接,以便该链接不会在翻译文件中硬编码。我用Symfony2表单调用它 条令映射:Php 如何添加包含Doctrine@Uniquentity约束内部链接的Symfony2翻译?,php,validation,symfony,doctrine-orm,symfony-forms,Php,Validation,Symfony,Doctrine Orm,Symfony Forms,我试图在我的条令映射中的@uniquentity消息中添加一个链接,以便该链接不会在翻译文件中硬编码。我用Symfony2表单调用它 条令映射: @UniqueEntity( fields={"email"}, message="form.error.email_exists" ) 翻译文件: <trans-unit id="a81086a8eea38842e4c8351657840086" resname="form.error.email_exists"> &
@UniqueEntity(
fields={"email"},
message="form.error.email_exists"
)
翻译文件:
<trans-unit id="a81086a8eea38842e4c8351657840086" resname="form.error.email_exists">
<source>form.error.email_exists</source>
<target>We have an account with that email. %link1%Forgot your login?%linkEnd%</target>
</trans-unit>
form.error.email_存在
我们在该电子邮件中有一个帐户。%link1%忘记登录?%linkEnd%
通常情况下,您只需通过翻译过滤器传递%link1%,但我不知道如何在注释中或是否可能这样做
提前感谢。我确定实现这一点的唯一方法是使用CDATA将链接硬编码到翻译文件中
<trans-unit id="a81086a8eea38842e4c8351657840086" resname="form.error.email_exists">
<source>form.error.email_exists</source>
<target>We have an account with that email. <![CDATA[<a href="www.example.com/forgotLogin">Forgot your login?</a>]]></target>
</trans-unit>
form.error.email_存在
我们在那封电子邮件上有一个帐户。
此解决方案的问题在于,无法在转换文件中指定特定域,但它至少可以工作。可以转换约束消息。为此,您需要一个名为validators.en.xml的翻译文件,其中en代表该语言。看