I am trying to add a link inside the @UniqueEntity message inside my Doctrine mapping so that the link is not hardcoded inside the translation file. I am invoking this with Symfony2 forms.
Doctrine mapping:
@UniqueEntity(
fields={"email"},
message="form.error.email_exists"
)
Translation file:
<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>
Normally you would just pass the %link1% through a translation filter, but I don't know how to do this within an annotation or if it is even possible.
Thanks in advance.
I determined that the only way to accomplish this was to hardcode the link into the translation file using 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>
The problem with this solution is that there is no way to specify a specific domain within the translation file, But it at least works.
Constraint messages can be translated. To do so you need a translation file that is called validators.en.xml where en stands for the language. See this chapter