gpt4 book ai didi

TYPO3 打字错误 : Language file with arguments

转载 作者:行者123 更新时间:2023-12-05 01:45:54 27 4
gpt4 key购买 nike

如何在 TypoScript 中呈现带参数的本地语言键? (用一个值替换 %s)

<trans-unit id="author">
<source>created by %s</source>
</trans-unit>

在 Fluid 中它做了以下事情:

<f:translate key="author" arguments="{0:authorName}"/>

现在通过 TypoScript?我尝试了以下方法:

page.10 = TEXT    
page.10.dataWrap = {LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:author|'Me'}

=====
通过 UserFunc 的解决方案 1:

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;
}
}

最佳答案

如果您的问题只是 %s 部分,那么您可以使用 stdwrap.replacement 来处理:

  stdWrap.replacement {
10 {
search = %s
replace = Me
}
}

参见 https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Replacement/Index.html

关于TYPO3 打字错误 : Language file with arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39366918/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com