TYPO3: use fluid's date view helper inline as argument for translate view helper

Christian Kirchhoff picture Christian Kirchhoff · May 6, 2013 · Viewed 8.9k times · Source

I am currently developing some extensions to use within TYPO3 6.

In one view I have database records with date fields. I can output the date values with the following:

<f:format.date format="d.m.Y H:i:s">{record.validend}</f:format.date>

However, I need a translated message, so I would like to use the translate view helper and put the formatted date in the arguments attribute. Without succes so far.

I tried:

<f:translate key="{msg_id}" arguments="{0: code, 1: {f:format.date(date: record.validend, format: 'd.m.Y H:i:s')}}" htmlEscape="0" />

…and…

<f:translate key="{msg_id}" arguments="{0: code, 1: {record.validend -> f:format.date(format: 'd.m.Y H:i:s')}}" htmlEscape="0" />

…following this guide: http://forge.typo3.org/projects/typo3v4-mvc/wiki/Fluid_Inline_Notation

However, there seems to be some syntax error in my notation forcing fluid to interpret the whole thing as a string, resulting in an error, cause the arguments attribut is expected to be an array.

Could anyone tell me if what I want is possible, and what syntax I need?

best regards

Christian

Answer

stmllr picture stmllr · May 11, 2013

You need to escape the quotes of format with backslashes.

The solution is:

<f:translate key="{msg_id}" arguments="{0: code, 1: '{f:format.date(date: record.validend, format: \'d.m.Y H:i:s\')}'}" htmlEscape="false" />