Fluid translate with link
If you want to translate some text with Fluid it’s easy. Just use the translate view Helper. Sometimes it even better to have some “markers” inside the translation so you won’t loose the context.
The following example shows how you can insert a translated link inside a translation (quite sick – I know…)
<f:translate key="text" htmlEscape="false" arguments="{0: '{f:translate(key: \'here\') -> f:link.action(action: \'show\')}'}" />
//locallang.xml
<label index="here">this link</label>
<label index="text">You can use %1$s to register.</label>
//output will be: You can use <a href="...">this link</a> to register.
The following code would also work but it’s much harder for the translators to understand what each label means.
<f:translate key="text_pre" /> <f:link.action action="show" /><f:translate key="here" /></f:link> <f:translate key="text_post" /> //locallang.xml <label index="here">this link</label> <label index="text_pre">You can use </label> <label index="text_post"> to register.</label> //output will be: You can use <a href="...">this link</a> to register.
Categories: Fluid