Project

General

Profile

Feature #17368 » languageCategories4.diff

Administrator Admin, 2007-08-27 23:44

View differences:

t3lib/class.t3lib_div.php (working copy)
* @return array LOCAL_LANG array in return.
*/
function readLLXMLfile($fileRef,$langKey) {
$langCategory=$GLOBALS['TSFE']->tmpl->setup['config.']['language.']['category'];
$altLangKey=$langCategory ? $langKey.'-'.$langCategory : '';
if (is_object($GLOBALS['LANG'])) {
$csConvObj = &$GLOBALS['LANG']->csConvObj;
} elseif (is_object($GLOBALS['TSFE'])) {
......
} else $csConvObj = NULL;
if (@is_file($fileRef) && $langKey && is_object($csConvObj)) {
// Set charset:
$origCharset = $csConvObj->parse_charset($csConvObj->charSetArray[$langKey] ? $csConvObj->charSetArray[$langKey] : 'iso-8859-1');
......
#'_'.basename($fileRef).
substr(basename($fileRef),10,15).
'_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$origCharset.'.cache';
// Check if cache file exists...
if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
// Read XML, parse it.
$xmlString = t3lib_div::getUrl($fileRef);
$xmlContent = t3lib_div::xml2array($xmlString);
......
// Set default LOCAL_LANG array content:
$LOCAL_LANG = array();
$LOCAL_LANG['default'] = $xmlContent['data']['default'];
$LOCAL_LANG['default'] = $xmlContent['data']['default'];
if($langCategory) $LOCAL_LANG['default-'.$langCategory] = $xmlContent['data']['default-'.$langCategory];
// Converting charset of default language from utf-8 to iso-8859-1 (since that is what the system would expect for default langauge in the core due to historical reasons)
// This conversion is unneccessary for 99,99% of all default labels since they are in english, therefore ASCII.
// However, an extension like TemplaVoila uses an extended character in its name, even in Default language. To accommodate that (special chars for default) this conversion must be made.
......
$LOCAL_LANG['default'][$labelKey] = $csConvObj->utf8_decode($labelValue,'iso-8859-1');
}
}
if (is_array($LOCAL_LANG['default-'.$langCategory])) {
foreach($LOCAL_LANG['default-'.$langCategory] as $labelKey => $labelValue) {
$LOCAL_LANG['default-'.$langCategory][$labelKey] = $csConvObj->utf8_decode($labelValue,'iso-8859-1');
}
}
// Specific language, convert from utf-8 to backend language charset:
// NOTICE: Converting from utf-8 back to "native" language may be a temporary solution until we can totally discard "locallang.php" files altogether (and use utf-8 for everything). But doing this conversion is the quickest way to migrate now and the source is in utf-8 anyway which is the main point.
if ($langKey!='default') {
......
// If no entry is found for the language key, then force a value depending on meta-data setting. By default an automated filename will be used:
if (!isset($xmlContent['data'][$langKey])) {
$LOCAL_LANG[$langKey] = t3lib_div::llXmlAutoFileName($fileRef, $langKey);
if($langCategory && !isset($xmlContent['data'][$altLangKey])) {
$LOCAL_LANG[$altLangKey] = t3lib_div::llXmlAutoFileName($fileRef, $altLangKey);
}
} else {
$LOCAL_LANG[$langKey] = $xmlContent['data'][$langKey];
$LOCAL_LANG[$langKey] = $xmlContent['data'][$langKey];
$LOCAL_LANG[$altLangKey] = $xmlContent['data'][$altLangKey];
}
// Checking if charset should be converted.
if (is_array($LOCAL_LANG[$langKey]) && $origCharset!='utf-8') {
foreach($LOCAL_LANG[$langKey] as $labelKey => $labelValue) {
$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$origCharset);
$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$origCharset);
}
}
if (is_array($LOCAL_LANG[$altLangKey]) && $origCharset!='utf-8') {
foreach($LOCAL_LANG[$altLangKey] as $labelKey => $labelValue) {
$LOCAL_LANG[$altLangKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$origCharset);
}
}
}
// Cache the content now:
......
// Read and parse XML content:
$local_xmlString = t3lib_div::getUrl($localized_file);
$local_xmlContent = t3lib_div::xml2array($local_xmlString);
$LOCAL_LANG[$langKey] = is_array($local_xmlContent['data'][$langKey]) ? $local_xmlContent['data'][$langKey] : array();
// Checking if charset should be converted.
if (is_array($LOCAL_LANG[$langKey]) && $origCharset!='utf-8') {
foreach($LOCAL_LANG[$langKey] as $labelKey => $labelValue) {
$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$origCharset);
if(is_array($labelValue)) {
foreach($labelValue as $catKey => $catValue) {
$LOCAL_LANG[$langKey][$labelKey][$catKey] = $csConvObj->utf8_decode($catValue,'iso-8859-1');
}
} else
$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$origCharset);
}
}
......
}
?>
?>
typo3/sysext/cms/tslib/class.tslib_pibase.php (working copy)
* @return string The value from LOCAL_LANG.
*/
function pi_getLL($key,$alt='',$hsc=FALSE) {
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.
} 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.
} elseif (isset($this->LOCAL_LANG['default'][$key])) {
$word = $this->LOCAL_LANG['default'][$key]; // No charset conversion because default is english and thereby ASCII
} else {
$word = $this->LLtestPrefixAlt.$alt;
}
$langCategory=$GLOBALS['TSFE']->tmpl->setup['config.']['language.']['category'];
if (isset($this->LOCAL_LANG[$this->LLkey][$key])) {
if(isset($langCategory) && isset($this->LOCAL_LANG[$this->LLkey.'-'.$langCategory][$key]))
$word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->LLkey.'-'.$langCategory][$key], $this->LOCAL_LANG_charset[$this->LLkey.'-'.$langCategory][$key]);
else
$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.
} elseif ($this->altLLkey && isset($this->LOCAL_LANG[$this->altLLkey][$key])) {
if(isset($langCategory) && isset($this->LOCAL_LANG[$this->altLLkey.'-'.$langCategory][$key]))
$word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->altLLkey.'-'.$langCategory][$key], $this->LOCAL_LANG_charset[$this->altLLkey.'-'.$langCategory][$key]);
else
$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.
} elseif (isset($this->LOCAL_LANG['default'][$key])) {
if(isset($langCategory) && isset($this->LOCAL_LANG['default-'.$langCategory][$key]))
$word = $this->LOCAL_LANG['default-'.$langCategory][$key]; // No charset conversion because default is english and thereby ASCII
else
$word = $this->LOCAL_LANG['default'][$key]; // No charset conversion because default is english and thereby ASCII
} else {
$word = $this->LLtestPrefixAlt.$alt;
}
$output = $this->LLtestPrefix.$word;
if ($hsc) $output = htmlspecialchars($output);
$output = $this->LLtestPrefix.$word;
if ($hsc) $output = htmlspecialchars($output);
return $output;
return $output;
}
/**
......
}
// NO extension of class - does not make sense here.
?>
?>
(5-5/6)