dsdt66064367 2015-09-23 17:21
浏览 28
已采纳

如何在Doctrine @UniqueEntity Constraint中添加包含链接的Symfony2翻译?

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.

  • 写回答

2条回答 默认 最新

  • dtsc14683 2015-09-23 18:51
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了