4

I made custom validation errors for an extension. Now I want to add an HTML link to an error message. tried to put HTML in language files (locallang.xlf) but it doesn't work.

Is there a way around this ?

Icepickle
  • 12,689
  • 3
  • 34
  • 48
user6800816
  • 503
  • 7
  • 26
  • 1
    More details please. How do you output `HTML`? Validation in backend or frontend? I think you need to use `CDATA` in `xlf` if you put htere `HTML` – iamandrewluca Dec 05 '17 at 08:52

2 Answers2

13

You can use CDATA to encapsulate the HTML:

<target><![CDATA[Here is <a href="https://...">useful info</a>]]></target>

You should consider generating the link URI from the outside and pass it as argument. Your translation could then look like this:

<target><![CDATA[Here is <a href="%s">useful info</a>]]></target>

In a Fluid template you would then do this:

<f:translate key="translation-id" arguments="{0: '{f:uri.typolink(...)}'}"/>

This would have the advantage that you can freely customize the link e.g. via TypoScript constants/setup.

Mathias Brodala
  • 5,905
  • 13
  • 30
4

Final step you should wrap the f:translate in a f:format.raw viewhelper. Example