Search code examples
typo3partialfluid

TYPO3 + Fluid: How to use f:translate as an argument for a partial?


I've a Fluid template with a partial. To fetch a localized string I'm using <f:translate key="myKey" />.

I wonder how to use f:translate as an argument for my partial.

According to the documentation there is a inline-notation: {f:translate(key: 'someKey', extensionName)} but this doesn't seem to work in my case and causes an error:

<f:render partial="Mail/MailHeader" arguments="{subject:{f:translate(key: 'myKey')}}" />

Error message:

Wed, 25 Nov 2020 10:25:10 +0100 [CRITICAL] request="8f19ae8768390" component="In2code.Powermail.Controller.FormController": Mail could not be sent - ["The argument "arguments" was registered with type "array", but is of type "string" in view helper "TYPO3\CMS\Fluid\ViewHelpers\RenderViewHelper"."]


Solution

  • I think you're missing the quotes around the subject variable

    <f:render partial="Mail/MailHeader" arguments="{subject:'{f:translate(key: \'myKey\')}'}" />