Adding a link inside translated content in Twig template

后端 未结 4 1507
余生分开走
余生分开走 2021-02-07 00:41

Inside a Twig template I would need to have a translated text that contains a link (the path should be generated by the Router, not statically embedded). Twig does not allow to

4条回答
  •  遇见更好的自我
    2021-02-07 01:23

    Twig:

    {{'body.term'|trans('%link_terms%' :app.request.getSchemeAndHttpHost()~path('terms')},'AcmeTerm')|raw }}
    

    AcmeTerm.yml

    body
        term: >
          
    

    where path('terms') is the route like:

    it__RG__terms                             ANY      ANY    ANY  /it/termini-e-condizioni
    en__RG__terms                             ANY      ANY    ANY  /en/terms-and-conditions
    

提交回复
热议问题