如果它是一个插件,您可以通过 TypoScript 的 _LOCAL_LANG
重写翻译字符串,例如 mindshape_cookie_hint
在其文档中建议的方式:
plugin.tx_myext_pi1._LOCAL_LANG.de.list_mode_1 = Der erste Modus
这需要您在 TypoScript 中管理翻译字符串,但远非理想。
更好、更通用的解决方案是通过locallangXMLOverride
注册自定义翻译字符串。这使您可以像所有其他地方一样管理这些翻译字符串。
从文档中可以了解到:
ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:cms/locallang_tca.xlf'][] =
'EXT:examples/Resources/Private/Language/custom.xlf';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']
['de']['EXT:news/Resources/Private/Language/locallang_modadministration.xlf'][] = 'EXT:examples/Resources/Private/Language/Overrides/de.locallang_modadministration.xlf';
第一行显示如何覆盖默认语言中的文件,第二行显示如何覆盖德语(“de”)翻译。德语语言文件的示例代码如下:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-03-09T18:44:59Z" product-name="examples">
<header/>
<body>
<trans-unit id="pages.title_formlabel" xml:space="preserve">
<source>Most important tile</source>
<target>Wichtigster Titel</target>
</trans-unit>
</body>
</file>
</xliff>
locallang.xlf
文件,以了解扩展使用的键,并在TypoScript模板中编写以下内容:plugin.tx_exampleplugin_pi1._LOCAL_LANG.it {
key1 = value1
key2 = value2
...
}
一般来说,如果我理解正确的话,您修改了插件的原始.xlf文件;这种做法并不推荐,因为更新会删除您的更改。
解决此问题的一个好方法是使用EXT:lfeditor扩展程序(https://extensions.typo3.org/extension/lfeditor/);仔细阅读其手册。
我将摘录该页面的一部分:
The
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']
allows to override both locallang-XML and XLIFF files. Actually this is not just about translations. Default language files can also be overridden. In the case of XLIFF files, the syntax is as follows (to be placed in an extension'sext_localconf.php
file):
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:cms/locallang_tca.xlf'][] = 'EXT:examples/Resources/Private/Language/custom.xlf'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['de']['EXT:news/Resources/Private/Language/locallang_modadministration.xlf'][] = 'EXT:examples/Resources/Private/Language/Overrides/de.locallang_modadministration.xlf';
The first line shows how to override a file in the default language, the second how to override a German ("de") translation. The German language file looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <xliff version="1.0"> <file source-language="en" datatype="plaintext" original="messages" date="2013-03-09T18:44:59Z" product-name="examples"> <header/> <body> <trans-unit id="pages.title_formlabel" xml:space="preserve"> <source>Most important tile</source> <target>Wichtigster Titel</target> </trans-unit> </body> </file> </xliff>
使用下面的Typoscript,您可以覆盖TYPO3扩展的单个翻译:
plugin.tx_myPlugin_pi1._LOCAL_LANG.de.key = value;
plugin.tx_myPlugin_pi1._LOCAL_LANG.en.key = value;
通常适用于每个扩展。希望这能帮到你!
问候!