[TYPO3-mvc] Fluid / Extbase: TranslateViewHelper - how to use arguments array for vsprintf?

Andreas Kiessling andreas.kiessling at web.de
Wed Jan 27 16:00:55 CET 2010


Hi,

i am using the TranslateViewHelper and was wondering, how to use the 
arguments attribute right, so that my collegues understand what i was 
doing there.

I fetch a string from a locallang.xml and want to replace one marker in 
there with a value from a record, that i have assigned to the view.

With regulare TYPO3 templates, i'd fetch the string, run sprintf and 
finally replace the marker in the template with my string. But as Fluid 
offers that functionality already, i'd like to use it without special 
preparations:

With

$this->view->assign('result', $result);

and in the template:
<f:translate key="fromlocallang" arguments="{result}" />

In the locallang.xml i need to use %22$s to fetch the field that i want 
to use from the record. Without looking at the database, nobody knows 
what this could mean and just using the position is not very safe...

I'd find it easier, if something like arguments="{result.name}, 
{result.name2}" could be used, so in locallang.xml %1$s would give me 
result.name

In the comments from php.net to vsprintf, an alternative usage with 
associative arrays is shown, so in the locallang.xml something like 
$(name)s could be used.

http://php.net/manual/de/function.vsprintf.php

Did i miss something in the viewhelper, so that i can create the array 
for vsprintf there? Or is this a missing feature?

Regards,
Andreas


More information about the TYPO3-project-typo3v4mvc mailing list