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

Andreas Kiessling andreas.kiessling at web.de
Thu Jan 28 13:52:22 CET 2010


On 28.01.2010 10:54, Sebastian Kurfürst wrote:
> Hey Andreas,
>
>> $this->view->assign('result', $result);
>>
>> and in the template:
>> <f:translate key="fromlocallang" arguments="{result}" />
> So, result is an array here, and you want to put only, lets say the name
> inside?
>
> THen just do:<f:translate key="fromlocallang" arguments="{1:
> result.name, 2: result.description}" />  in there.
>

Wow! Thanks a lot for that example. Works like a charm.

I searched for some time for an example and ended up, writing my own 
viewhelper, that accepts a single field as argument, since i only needed 
one placeholder.


>> 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.
> That would be very cool, but actually as I understand the comments, this
> is *not* done by the out-of-the-box vsprintf function. Or am I wrong? :-)

You're right, vsprintf does not worke like that out of-the-box. I did 
not try that wrapper function dsprintf, but the shown example was imho 
very intuitive.

I think i can live with the current situation for my project, so thanks 
again for showing.

After writing these lines, i remembered the CycleViewHelper, where an 
example array was built just like that in the comments...

Regards,
Andreas


More information about the TYPO3-project-typo3v4mvc mailing list