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
rebdirdo's solution is not really safe as it's not escaping whole message. It is not working correctly for messages like "don't use tag, use tag instead. %link_start%Here%link_end% you can find why."
, because the tags will be not escaped and will be not visible.
working approach:
translation file:
advises.strong: don't use tag, use tag instead. %link_start%Here%link_end% you can find why.
twig file:
{{ 'advises.strong'|trans|nl2br|replace({'%link_start%': '', '%link_end%': ''})|raw }}
Note the nl2br filter. It is necessary to put some filter there to make the raw filter working only for the link tags.