// 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 $labelsCharset=''; // Charset of the labels from locallang (based on $this->lang)
- var $convCharsetToFrom=''; // Set to the charsets to convert from/to IF there are any difference. Otherwise this stays a string
var $LL_labels_cache=array();
var $LL_files_cache=array();
$extPrfx='EXT:';
}
$parts = explode(':',$restStr);
- $parts[0]=$extPrfx.$parts[0];
+ $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->csConv($this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]));
+ $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];
}
* @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
*/
function readLLfile($fileRef) {
- return t3lib_div::readLLfile($fileRef,$this->lang);
+ return t3lib_div::readLLfile($fileRef, $this->lang, $this->renderCharset);
}
/**
* @param array The locallang array in which to search
* @return string Label value of $index key.
*/
- function getLLL($index,$LOCAL_LANG) {
+ function getLLL($index, &$LOCAL_LANG) {
if (strcmp($LOCAL_LANG[$this->lang][$index],'')) {
return $LOCAL_LANG[$this->lang][$index];
} else {
// 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.
- $this->labelsCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$this->lang] ? $this->csConvObj->charSetArray[$this->lang] : 'iso-8859-1');
- if ($this->renderCharset != $this->labelsCharset) {
- $this->convCharsetToFrom = array(
- 'from' => $this->labelsCharset,
- 'to' => $this->renderCharset
- );
- }
}
/**
* Converts the charset of the input string if applicable.
- * The "from" charset is determined by the TYPO3 system charset for the current language key ($this->lang)
- * The "to" charset is determined by the currently used charset for the page which is "iso-8859-1" by default or set by $GLOBALS['TSFE']->config['config']['metaCharset']
+ * The "to" charset is determined by the currently used charset for the page which is "iso-8859-1" by default or set by $GLOBALS['TSFE']->config['config']['renderCharset']
* Only if there is a difference between the two charsets will a conversion be made
* The conversion is done real-time - no caching for performance at this point!
*
if ($from) {
$output = $this->csConvObj->conv($str,$this->csConvObj->parse_charset($from),$this->renderCharset,1);
return $output ? $output : $str;
- } elseif (is_array($this->convCharsetToFrom)) {
- return $this->csConvObj->conv($str,$this->convCharsetToFrom['from'],$this->convCharsetToFrom['to'],1);
} else {
return $str;
}
/***************************************************************
* Copyright notice
*
-* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+* (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* @return string The value from LOCAL_LANG.
*/
function pi_getLL($key,$alt='',$hsc=FALSE) {
+ // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG
if (isset($this->LOCAL_LANG[$this->LLkey][$key])) {
- $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->LLkey][$key], $this->LOCAL_LANG_charset[$this->LLkey][$key]); // The "from" charset is normally empty and thus it will convert from the charset of the system language, but if it is set (see ->pi_loadLL()) it will be used.
+ $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->LLkey][$key], $this->LOCAL_LANG_charset[$this->LLkey][$key]);
} elseif ($this->altLLkey && isset($this->LOCAL_LANG[$this->altLLkey][$key])) {
- $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->altLLkey][$key], $this->LOCAL_LANG_charset[$this->altLLkey][$key]); // The "from" charset is normally empty and thus it will convert from the charset of the system language, but if it is set (see ->pi_loadLL()) it will be used.
+ $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->altLLkey][$key], $this->LOCAL_LANG_charset[$this->altLLkey][$key]);
} elseif (isset($this->LOCAL_LANG['default'][$key])) {
$word = $this->LOCAL_LANG['default'][$key]; // No charset conversion because default is english and thereby ASCII
} else {
if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) {
$basePath = t3lib_extMgm::extPath($this->extKey).dirname($this->scriptRelPath).'/locallang.php';
- // php or xml as source: In any case the charset will be that of the system language.
- // However, this function guarantees only return output for default language plus the specified language (which is different from how 3.7.0 dealt with it)
- $this->LOCAL_LANG = t3lib_div::readLLfile($basePath,$this->LLkey);
+ // Read the strings in the required charset (since TYPO3 4.2)
+ $this->LOCAL_LANG = t3lib_div::readLLfile($basePath,$this->LLkey,$GLOBALS['TSFE']->renderCharset);
if ($this->altLLkey) {
$tempLOCAL_LANG = t3lib_div::readLLfile($basePath,$this->altLLkey);
$this->LOCAL_LANG = array_merge(is_array($this->LOCAL_LANG) ? $this->LOCAL_LANG : array(),$tempLOCAL_LANG);
foreach($lA as $llK => $llV) {
if (!is_array($llV)) {
$this->LOCAL_LANG[$k][$llK] = $llV;
- if ($k != 'default') {
- $this->LOCAL_LANG_charset[$k][$llK] = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']; // For labels coming from the TypoScript (database) the charset is assumed to be "forceCharset" and if that is not set, assumed to be that of the individual system languages (thus no conversion)
- }
+ // For labels coming from the TypoScript (database) the charset is assumed to be "forceCharset" and if that is not set, assumed to be that of the individual system languages
+ $this->LOCAL_LANG_charset[$k][$llK] = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : $GLOBALS['TSFE']->csConvObj->charSetArray[$k];
}
}
}
var $LL_files_cache=array(); // Internal cache for read LL-files
var $LL_labels_cache=array(); // Internal cache for ll-labels (filled as labels are requested)
- // Internal charset conversion:
- var $origCharSet=''; // If set, then it means that the this->charSet is set to a forced, common value for the WHOLE backend regardless of user language. And THIS variable will contain the original charset for the language labels. With ->csConvObj we must then convert the original charset to the charset used in the backend from now on.
-
/**
* instance of the "t3lib_cs" class. May be used by any application.
*
// If a forced charset is used and different from the charset otherwise used:
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']!=$this->charSet) {
// Set the forced charset:
- $this->origCharSet = $this->charSet;
$this->charSet = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'];
if ($this->charSet!='utf-8' && !$this->csConvObj->initCharset($this->charSet)) {
t3lib_BEfunc::typo3PrintError ('The forced character set "'.$this->charSet.'" was not found in t3lib/csconvtbl/','Forced charset not found');
exit;
}
- if ($this->origCharSet!='utf-8' && !$this->csConvObj->initCharset($this->origCharSet)) {
- t3lib_BEfunc::typo3PrintError ('The original character set "'.$this->origCharSet.'" was not found in t3lib/csconvtbl/','Forced charset not found');
- exit;
- }
}
}
*/
function hscAndCharConv($lStr,$hsc) {
$lStr = $hsc ? htmlspecialchars($lStr) : $lStr;
- if ($this->origCharSet) {
- $lStr = $this->csConvObj->conv($lStr,$this->origCharSet,$this->charSet,1);
- }
+
+ // labels returned from a locallang file used to be in the language of the charset. Since TYPO3 4.1 they are always in the charset of the BE.
+
return $lStr;
}
* @return array Value of $LOCAL_LANG found in the included file. If that array is found it's returned. Otherwise an empty array
*/
function readLLfile($fileRef) {
- return t3lib_div::readLLfile($fileRef,$this->lang);
+ return t3lib_div::readLLfile($fileRef, $this->lang, $this->charSet);
}
/**
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lang/lang.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lang/lang.php']);
}
-?>
+?>
\ No newline at end of file