how can I render a locallang key with arguments in TypoScript? (replace the %s with a value)
<trans-unit id="author">
<source>created by %s</source>
</trans-unit>
In Fluid it's done the following:
<f:translate key="author" arguments="{0:authorName}"/>
And now via TypoScript? I tried the following:
page.10 = TEXT
page.10.dataWrap = {LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:author|'Me'}
=====
Solution 1 via UserFunc:
page.10 = USER_INT
page.10 {
userFunc = FluidTranslate->main
extensionName = my_ext
key = tx_myext_domain_model_mymodel.author
arguments.0 = Me
}
PHP:
<?php
class FluidTranslate
{
public function main($content, $conf)
{
$extensionName = $conf['extensionName'];
$key = $conf['key'];
$arguments = $conf['arguments.'];
$value = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, $extensionName, $arguments);
return $value;
}
}
I don't think this is possible in the TEXT
object yet, because for resolving the LLL:
from TS the method TypoScriptFrotnendController->sL()
is used.
You could however call a user function with the USER
object and fetch your label there with LocalizationUtility::translate()
where you can pass arguments.