Inside TYPO3
| < 3.8.11. How to acquire labels from the $LANG object | Table Of Content | 3.9. Context Sensitive Help (CSH) > |
3.8.12. Overriding LOCAL_LANG values
TYPO3 offers an API for overriding LOCAL_LANG values in the backend by custom files you set up. 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 merged together. Lets 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:
-
First, find out where the label is outputted so you can 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. -
Create an alternative $LOCAL_LANG array with the labelkeys you want to override.
I have created the file "typo3conf/llor_test.php" which looks like this:<?php
$LOCAL_LANG = array(
"default" => array("buttons.logout" => "End session",),"dk" => array("buttons.logout" => "Afslut admin",));
?>
Notice how it contains both an English and Danish alternative.
-
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['BE']['XLLfile'] array which points to the overriding file:$TYPO3_CONF_VARS['BE']['XLLfile']['EXT:lang/locallang_core.php']='typo3conf/llor_test.php';
The filepath of "typo3conf/llor_test.php" is relative to the PATH_site constant. You could also keep the file in an extension in which case you would have to enter the file reference like 'EXT:myext/llor_test.php' - and the file will automatically be located wherever you extension is installed.
This example includes a function call to $LANG->sL(). If the labels are fetched by $LANG->getLL() as they are in most modules you will have to make sure that the locallang file you need to override was included by the function $LANG->includeLLFile() since that will detect any "XLLfile" you might have configured - otherwise the API will not work of course.