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" />
Question
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
Solution
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" />
OTHER TIPS
The right way to use format.date as variable is:
{f:format.date(format : 'd-m-Y H:i:s', date : '@1368093280')}
I tested your request and it seems that it isnt possible to call a ViewHelper inside the argument arguments
of a ViewHelper.
So you should try something else like a custom ViewHelper or format your date in the controller so you have a variable that contains the formatted date:
{f:translate(key : msg.id, arguments : {0 : msg.date})}