简体   繁体   中英

Add translation to TYPO3 Extension via Typoscript

is there a way to substitute/override the default de.locallang.xlf of the extension via Typoscript? I want to change the text of mindshape_cookie_hint in a way that will survive an update.

If it is a plugin you can override translations in TypoScript via _LOCAL_LANG which is also what mindshape_cookie_hint suggests in its docs .

This requires you to manage your translation strings in TypoScript though which is far from ideal. A better and more general solution is registering custom translations via locallangXMLOverride . This allows you to manage these translations just like everywhere else.

You are looking for this https://wiki.typo3.org/TypoScript_language_additions,_override

As written by Ghanshyam Bhava in his answer, you can just take a look at the locallang.xlf file in the plugin folder in the file system to have an overview of the keys the extension uses and then write in your TypoScript template:

plugin.tx_exampleplugin_pi1._LOCAL_LANG.it {

   key1 = value1
   key2 = value2
   ...

} 

see also https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Plugin/Index.html#local-lang-lang-key-label-key

In a general way, correct me if I am wrong, I think that you have modified the original .xlf file of the plugin; this procedure is not recommended for the reason you are facing: an update would delete your changes.

A good way to deal with this problem could be for example using the extension EXT:lfeditor ( https://extensions.typo3.org/extension/lfeditor/ ); read carefully its manual.

Another source (official documentation): https://docs.typo3.org/typo3cms/CoreApiReference/latest/ApiOverview/Internationalization/ManagingTranslations.html?highlight=locallangxmloverride#custom-translations

I'll take an excerpt from that page:

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's ext_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> 

With below typoscript you can overwrite individual translations for TYPO3 Extension:

plugin.tx_myPlugin_pi1._LOCAL_LANG.de.key = value; 
plugin.tx_myPlugin_pi1._LOCAL_LANG.en.key = value;

Generally common for every extension. Hope this will help you!

Greetings!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM