user6800816
user6800816

Reputation: 543

HTML in language files

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 ?

Upvotes: 4

Views: 3250

Answers (2)

Muhammad Awais
Muhammad Awais

Reputation: 41

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

Upvotes: 4

Mathias Brodala
Mathias Brodala

Reputation: 6460

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.

Upvotes: 15

Related Questions