From 1526d4de16d5a530a72029fb4f8c9c182b63b065 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Wed, 6 Jul 2011 18:37:12 +0200
Subject: [PATCH] [TASK] Language handling: splitLabels and locallang.php
 should be removed

The TYPO3 core currently handles three types of language labels:
* splitlabels (very very old): Based on the constant TYPO3_languages, a
  string is split by |. The only use was the loginLabels but this was
  changed in 4.3, so they only act as fallback right now.
* locallang.php (very old): An array for each language in a .php file.
* locallang.xml (currently used): An XML file with labels.

Change-Id: Idd6905776af755cf54258fe6723ca1226816655d
Resolves: #26519
Reviewed-on: http://review.typo3.org/3058
Reviewed-by: Stefan Neufeind
Reviewed-by: Oliver Hader
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Tested-by: Oliver Hader
---
 t3lib/config_default.php                  |   1 -
 typo3/index.php                           |   2 +
 typo3/sysext/cms/tslib/class.tslib_fe.php |  43 +++------
 typo3/sysext/lang/lang.php                | 111 ++++++++--------------
 4 files changed, 56 insertions(+), 101 deletions(-)

diff --git a/t3lib/config_default.php b/t3lib/config_default.php
index 9540a7d94052..d78be73926ef 100644
--- a/t3lib/config_default.php
+++ b/t3lib/config_default.php
@@ -475,7 +475,6 @@ $TYPO3_CONF_VARS = array(
 		'fileDenyPattern' => FILE_DENY_PATTERN_DEFAULT ,	// A perl-compatible regular expression (without delimiters!) that - if it matches a filename - will deny the file upload/rename or whatever in the webspace. For security reasons, files with multiple extensions have to be denied on an Apache environment with mod_alias, if the filename contains a valid php handler in an arbitary position. Also, ".htaccess" files have to be denied. Matching is done case-insensitive. Default value is stored in constant FILE_DENY_PATTERN_DEFAULT
 		'interfaces' => 'backend',					// This determines which interface options is available in the login prompt and in which order (All options: ",backend,frontend")
 		'useOnContextMenuHandler' => TRUE,		// Boolean: If set, the context menus (clickmenus) in the backend are activated on right-click - although this is not a XHTML attribute!
-		'loginLabels' => 'Username|Password|Interface|Log In|Log Out|Backend,Front End,Traditional Backend|Administration Login on ###SITENAME###|(Note: Cookies and JavaScript must be enabled!)|Important Messages:|Your login attempt did not succeed. Make sure to spell your username and password correctly, including upper/lowercase characters.',		// Language labels of the login prompt, separated with a pipe symbol (|). These should not be used anymore to change the labels since TYPO3 4.3, furthermore overload the labels with , see EXT:lang/locallang_login.xml for the used labels.
 		'loginNews' => array(),						// In this array you can define news-items for the login screen. To this array, add arrays with assoc keys 'date', 'header', 'content' (HTML content) and for those appropriate value pairs
 		'loginNewsTitle' => '',					// Define alternative header message for the LoginNews. If this var is empty, the default header "Important messages:" is displayed.
 		'notificationPrefix' => '[TYPO3 Note]',	// String: Used to prefix the subject of mails sent in the taskcenter
diff --git a/typo3/index.php b/typo3/index.php
index b2622228b3ba..3419c694f097 100644
--- a/typo3/index.php
+++ b/typo3/index.php
@@ -752,11 +752,13 @@ class SC_index {
 	 * using the llxml extension
 	 *
 	 * @return	void
+	 * @deprecated since TYPO3 4.6, remove in TYPO3 4.8
 	 */
 	protected function mergeOldLoginLabels() {
 			// Getting login labels
 		$oldLoginLabels = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels']);
 		if ($oldLoginLabels != '') {
+			t3lib_div::deprecationLog('The use of $GLOBALS[\'TYPO3_CONF_VARS\'][\'BE\'][\'loginLabels\'] has been deprecated as of TYPO3 4.3, please use the according locallang.xml file.');
 				// md5 hash of the default loginLabels string
 			$defaultOldLoginLabelsHash = 'bcf0d32e58c6454ea50c6c956f1f18f0';
 				// compare loginLabels from TYPO3_CONF_VARS to default value
diff --git a/typo3/sysext/cms/tslib/class.tslib_fe.php b/typo3/sysext/cms/tslib/class.tslib_fe.php
index 58558e6c3f12..d5a47cd07511 100644
--- a/typo3/sysext/cms/tslib/class.tslib_fe.php
+++ b/typo3/sysext/cms/tslib/class.tslib_fe.php
@@ -233,7 +233,6 @@
 
 		// LANG:
 	var $lang='';						// Set to the system language key (used on the site)
-	var $langSplitIndex=0;				// Set to the index number of the language key
 	var $LL_labels_cache=array();
 	var $LL_files_cache=array();
 
@@ -4484,26 +4483,23 @@ if (version == "n3") {
 	 * @return	string		Label value, if any.
 	 */
 	function sL($input)	{
-		if (strcmp(substr($input,0,4),'LLL:'))	{
-			$t = explode('|',$input);
-			return $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0];
-		} else {
-			if (!isset($this->LL_labels_cache[$this->lang][$input])) {	// If cached label
-				$restStr = trim(substr($input,4));
-				$extPrfx='';
-				if (!strcmp(substr($restStr,0,4),'EXT:'))	{
-					$restStr = trim(substr($restStr,4));
-					$extPrfx='EXT:';
-				}
-				$parts = explode(':',$restStr);
-				$parts[0] = $extPrfx.$parts[0];
-				if (!isset($this->LL_files_cache[$parts[0]]))	{	// Getting data if not cached
-					$this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
-				}
-				$this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]);
+			// If cached label
+		if (!isset($this->LL_labels_cache[$this->lang][$input])) {
+			$restStr = trim(substr($input,4));
+			$extPrfx='';
+			if (!strcmp(substr($restStr,0,4),'EXT:'))	{
+				$restStr = trim(substr($restStr,4));
+				$extPrfx='EXT:';
+			}
+			$parts = explode(':',$restStr);
+			$parts[0] = $extPrfx.$parts[0];
+				// Getting data if not cached
+			if (!isset($this->LL_files_cache[$parts[0]])) {
+				$this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
 			}
-			return $this->LL_labels_cache[$this->lang][$input];
+			$this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]);
 		}
+		return $this->LL_labels_cache[$this->lang][$input];
 	}
 
 	/**
@@ -4535,7 +4531,6 @@ if (version == "n3") {
 
 	/**
 	 * Initializing the getLL variables needed.
-	 * Sets $this->langSplitIndex based on $this->config['config']['language']
 	 *
 	 * @return	void
 	 */
@@ -4545,14 +4540,6 @@ if (version == "n3") {
 		$this->lang = $this->config['config']['language'] ? $this->config['config']['language'] : 'default';
 		$this->getPageRenderer()->setLanguage($this->lang);
 
-		$ls = explode('|',TYPO3_languages);
-		foreach ($ls as $i => $v) {
-			if ($v == $this->lang) {
-				$this->langSplitIndex = $i;
-				break;
-			}
-		}
-
 			// Setting charsets:
 		$this->renderCharset = $this->csConvObj->parse_charset($this->config['config']['renderCharset'] ? $this->config['config']['renderCharset'] : ($this->TYPO3_CONF_VARS['BE']['forceCharset'] ? $this->TYPO3_CONF_VARS['BE']['forceCharset'] : $this->defaultCharSet));	// Rendering charset of HTML page.
 		$this->metaCharset = $this->csConvObj->parse_charset($this->config['config']['metaCharset'] ? $this->config['config']['metaCharset'] : $this->renderCharset);	// Output charset of HTML page.
diff --git a/typo3/sysext/lang/lang.php b/typo3/sysext/lang/lang.php
index 6975e4223ad1..4d76e4e39a96 100755
--- a/typo3/sysext/lang/lang.php
+++ b/typo3/sysext/lang/lang.php
@@ -53,15 +53,6 @@ class language {
 	 */
 	public $lang = 'default';
 
-	/**
-	 * Values like the labels in the tables.php-document are split by '|'.
-	 * This values defines which language is represented by which position
-	 * in the resulting array after splitting a value. (NOTICE: Obsolete concept!)
-	 *
-	 * @var string
-	 */
-	public $langSplit = 'default';
-
 	/**
 	 * Default charset in backend
 	 *
@@ -98,12 +89,6 @@ class language {
 	 */
 	public $moduleLabels = array();
 
-	/**
-	 * Internal, Points to the position of the current language key as found in constant TYPO3_languages
-	 * @var int
-	 */
-	public $langSplitIndex = 0;
-
 	/**
 	 * Internal cache for read LL-files
 	 *
@@ -152,24 +137,17 @@ class language {
 			// Initialize the parser factory object
 		$this->parserFactory = t3lib_div::makeInstance('t3lib_l10n_Factory');
 
-			// Internally setting the list of TYPO3 backend languages.
-		$this->langSplit = TYPO3_languages;
-
 			// Finding the requested language in this list based
 			// on the $lang key being inputted to this function.
-		$ls = explode('|', $this->langSplit);
-
-		foreach ($ls as $i => $v) {
-				// Language is found. Configure it:
-			if ($v == $lang) {
-					// The index of the language as found in the TYPO3_languages list
-				$this->langSplitIndex = $i;
-					// The current language key
-				$this->lang = $lang;
-				if ($this->charSetArray[$this->lang]) {
-						// The charset if different from the default.
-					$this->charSet = $this->charSetArray[$this->lang];
-				}
+		$ls = explode('|', TYPO3_languages);
+
+			// Language is found. Configure it:
+		if (in_array($lang, $ls)) {
+				// The current language key
+			$this->lang = $lang;
+			if ($this->charSetArray[$this->lang]) {
+					// The charset if different from the default.
+				$this->charSet = $this->charSetArray[$this->lang];
 			}
 		}
 
@@ -366,51 +344,40 @@ class language {
 	 * @access	public
 	 */
 	public function sL($input, $hsc = FALSE) {
-		// Using obsolete 'language-splitted' labels:
-		if (strcmp(substr($input, 0, 4), 'LLL:')) {
-			$t = explode('|', $input);
-			$out = $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0];
-			if ($hsc) {
-				$out = htmlspecialchars($out);
+			// If cached label
+		if (!isset($this->LL_labels_cache[$this->lang][$input])) {
+			$restStr = trim(substr($input, 4));
+			$extPrfx = '';
+
+				// ll-file refered to is found in an extension.
+			if (!strcmp(substr($restStr, 0, 4), 'EXT:')) {
+				$restStr = trim(substr($restStr, 4));
+				$extPrfx = 'EXT:';
 			}
-			return $out;
-			// LOCAL_LANG:
-		} else {
-				// If cached label
-			if (!isset($this->LL_labels_cache[$this->lang][$input])) {
-				$restStr = trim(substr($input, 4));
-				$extPrfx = '';
-
-					// ll-file refered to is found in an extension.
-				if (!strcmp(substr($restStr, 0, 4), 'EXT:')) {
-					$restStr = trim(substr($restStr, 4));
-					$extPrfx = 'EXT:';
-				}
-				$parts = explode(':', $restStr);
-				$parts[0] = $extPrfx . $parts[0];
-
-					// Getting data if not cached
-				if (!isset($this->LL_files_cache[$parts[0]])) {
-					$this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
-
-						// If the current language is found in another file, load that as well:
-					$lFileRef = $this->localizedFileRef($parts[0]);
-					if ($lFileRef && is_string($this->LL_files_cache[$parts[0]][$this->lang])
-							&& $this->LL_files_cache[$parts[0]][$this->lang] == 'EXT') {
-						$tempLL = $this->readLLfile($lFileRef);
-						$this->LL_files_cache[$parts[0]][$this->lang] = $tempLL[$this->lang];
-					}
+			$parts = explode(':', $restStr);
+			$parts[0] = $extPrfx . $parts[0];
+
+				// Getting data if not cached
+			if (!isset($this->LL_files_cache[$parts[0]])) {
+				$this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
+
+					// If the current language is found in another file, load that as well:
+				$lFileRef = $this->localizedFileRef($parts[0]);
+				if ($lFileRef && is_string($this->LL_files_cache[$parts[0]][$this->lang])
+						&& $this->LL_files_cache[$parts[0]][$this->lang] == 'EXT') {
+					$tempLL = $this->readLLfile($lFileRef);
+					$this->LL_files_cache[$parts[0]][$this->lang] = $tempLL[$this->lang];
 				}
-				$this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1], $this->LL_files_cache[$parts[0]]);
-			}
-				// For the cached output charset conversion has already happened!
-				// So perform HSC right here.
-			$output = $this->LL_labels_cache[$this->lang][$input];
-			if ($hsc) {
-				$output = t3lib_div::deHSCentities(htmlspecialchars($output));
 			}
-			return $output . $this->debugLL($input);
+			$this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1], $this->LL_files_cache[$parts[0]]);
+		}
+			// For the cached output charset conversion has already happened!
+			// So perform HSC right here.
+		$output = $this->LL_labels_cache[$this->lang][$input];
+		if ($hsc) {
+			$output = t3lib_div::deHSCentities(htmlspecialchars($output));
 		}
+		return $output . $this->debugLL($input);
 	}
 
 	/**
-- 
GitLab