Updates for TYPO3 4.3
|Priority:||Should have||Due date:|
This has originally been reported by Christian Kuhn:
Christian, 2009-08-31 #20955
2.8 LOCALISATION -> Overriding LOCAL_LANG values
TYPO3 offers an API for overriding LOCAL_LANG values by custom XML files. Provided that the inclusion of the locallang file is handled by the language class then your custom file will be included after the real locallang file(s) and the arrays will be merged together. Let's look at an example: Example We want to change the label of the logout button from "Logout" to "End session". What we do is this: 1. First, find out where in the PHP code the label is output so that you know the label key and locallang file. In this case the script "alt_menu.php" outputs the button which is generated by a function from the file "class.alt_menu_functions.inc". Looking into this file we find that the line "$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout')" fetches the label for the button. 2. Create an alternative XML file with the labelkeys you want to override (in our case "buttons.logout"). I have created the file "typo3conf/langoverride_core.xml" which looks like this: <?xml version="1.0" encoding="utf-8" standalone="yes"> <T3locallang> <data type="array"> <languageKey index="default" type="array"> <label index="buttons.logout">End session</label> </languageKey> <languageKey index="dk" type="array"> <label index="buttons.logout">Afslut session</label> </languageKey> </data> </T3locallang> Notice how it contains both an English and Danish label. 3. Configure the script to override values in the file "EXT:lang/locallang_core.php" This is simply done by adding an entry in the $TYPO3_CONF_VARS['SYS']['locallangXMLOverride'] array which points to the overriding file: $TYPO3_CONF_VARS['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.php']['myLangOverride'] = 'typo3conf/langoverride_core.xml'; The file path of "typo3conf/langoverride_core.xml" is relative to the PATH_site constant. You can also keep the file in an extension. In that case you would have to enter the file reference like 'EXT:myext/langoverride_core.xml' - and the file will automatically be found wherever your extension is installed. The name of the array key 'myLangOverride' is arbitrary, but you are advised to give it a meaningful (and unique) value. Additionally in the frontend it is also possible to override labels with the Typoscript key "_LOCAL_LANG". This takes precedence over locallangXMLOverride labels.
*Change the word ''XLLfile'' in 2.8 LOCALISATION -> Including locallang files in modules to ''locallangXMLOverride''.
*Add the following paragraph somewhere:
Note: Using the array $TYPO3_CONF_VARS['BE']['XLLoverride'] is deprecated and should not be done anymore. $TYPO3_CONF_VARS['SYS']['locallangXMLOverride'] is more flexible and also works for the frontend.
|related to Core - Feature #20955: Override FE labels with XML files||Resolved||2009-08-30|