2 namespace TYPO3\CMS\Lang;
121 public function init(
$lang)
125 $this->charSetArray = $this->csConvObj->charSetArray;
137 foreach (
$locales->getLocaleDependencies($this->lang) as $language) {
138 $this->languageDependencies[] = $language;
141 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lang'][
'debug']) {
142 $this->debugKey =
true;
166 if (is_array($arr)) {
167 foreach ($arr as $k => $larr) {
168 if (!isset($this->moduleLabels[$k])) {
169 $this->moduleLabels[$k] = array();
171 if (is_array($larr)) {
172 foreach ($larr as $l => $v) {
173 $this->moduleLabels[$k][$prefix . $l] = $v;
195 return $this->csConvObj->utf8_to_entities($str);
206 return $this->debugKey ?
'[' . $value .
']' :
'';
217 public function getLL($index, $hsc =
false)
230 public function getLLL($index, $localLanguage, $hsc =
false)
234 if (isset($localLanguage[$this->lang][$index])) {
235 $value = is_string($localLanguage[$this->lang][$index])
237 : $localLanguage[
$this->lang][$index][0][
'target'];
238 }
elseif (isset($localLanguage[
'default'][$index])) {
239 $value = is_string($localLanguage[
'default'][$index])
240 ? $localLanguage[
'default'][$index]
241 : $localLanguage[
'default'][$index][0][
'target'];
246 $value = htmlspecialchars($value);
248 return $value . $this->
debugLL($index);
262 public function sL($input, $hsc =
false)
265 if (isset($this->LL_labels_cache[$this->lang][$identifier])) {
266 return $this->LL_labels_cache[
$this->lang][$identifier];
268 if (strpos($input,
'LLL:') === 0) {
269 $restStr = trim(substr($input, 4));
272 if (strpos($restStr,
'EXT:') === 0) {
273 $restStr = trim(substr($restStr, 4));
276 $parts = explode(
':', $restStr);
277 $parts[0] = $extPrfx . $parts[0];
279 if (!isset($this->LL_files_cache[$parts[0]])) {
280 $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
283 if ($lFileRef && $this->LL_files_cache[$parts[0]][$this->lang] ===
'EXT') {
284 $tempLL = $this->readLLfile($lFileRef);
288 $output = $this->
getLLL($parts[1], $this->LL_files_cache[$parts[0]]);
294 $output = htmlspecialchars($output, ENT_COMPAT,
'UTF-8',
false);
296 $output .= $this->
debugLL($input);
297 $this->LL_labels_cache[
$this->lang][$identifier] = $output;
313 if (is_array(
$GLOBALS[
'TCA_DESCR'][$table]) && !isset(
$GLOBALS[
'TCA_DESCR'][$table][
'columns']) && is_array(
$GLOBALS[
'TCA_DESCR'][$table][
'refs'])) {
315 $GLOBALS[
'TCA_DESCR'][$table][
'columns'] = array();
317 foreach (
$GLOBALS[
'TCA_DESCR'][$table][
'refs'] as $llfile) {
320 if (is_array($localLanguage[
'default'])) {
321 foreach ($localLanguage[
'default'] as $lkey => $lVal) {
326 $keyParts = explode(
'.', $lkey);
327 $keyPartsCount = count($keyParts);
330 $specialInstruction = $keyParts[$keyPartsCount - 1] ===
'+';
331 if ($specialInstruction) {
332 array_pop($keyParts);
337 if ($keyPartsCount > 2) {
338 $type = array_pop($keyParts);
339 $fieldName = implode(
'.', $keyParts);
341 $fieldName = $keyParts[0];
342 $type = $keyParts[1];
345 if ($fieldName ===
'_') {
348 if ($fieldName !==
'' && $fieldName[0] ===
'_') {
349 $fieldName = substr($fieldName, 1);
352 $label = $lVal[0][
'target'] ? :
354 if ($specialInstruction) {
355 $GLOBALS[
'TCA_DESCR'][$table][
'columns'][$fieldName][$type] .= LF . $label;
358 $GLOBALS[
'TCA_DESCR'][$table][
'columns'][$fieldName][$type] = $label;
375 public function includeLLFile($fileRef, $setGlobal =
true, $mergeLocalOntoDefault =
false)
377 $globalLanguage = array();
379 $localLanguage = $this->readLLfile($fileRef);
380 if (is_array($localLanguage) && !empty($localLanguage)) {
383 $globalLanguage = (array)
$GLOBALS[
'LOCAL_LANG'];
386 $globalLanguage = $localLanguage;
390 if ($lFileRef && (
string)$globalLanguage[$this->lang] ===
'EXT') {
391 $localLanguage = $this->readLLfile($lFileRef);
395 if ($mergeLocalOntoDefault && $this->lang !==
'default' && is_array($globalLanguage[$this->lang]) && is_array($globalLanguage[
'default'])) {
398 $globalLanguage[
'default'] = array_merge($globalLanguage[
'default'], $globalLanguage[$this->lang]);
399 unset($globalLanguage[$this->lang]);
404 return $globalLanguage;
406 $GLOBALS[
'LOCAL_LANG'] = $globalLanguage;
417 protected function readLLfile($fileRef)
426 if ($this->lang !==
'default') {
427 $languages = array_reverse($this->languageDependencies);
429 $languages = array(
'default');
431 $localLanguage = array();
432 foreach ($languages as $language) {
433 $tempLL = $languageFactory->getParsedData($fileRef, $language, $this->charSet);
434 $localLanguage[
'default'] = $tempLL[
'default'];
435 if (!isset($localLanguage[$this->lang])) {
436 $localLanguage[
$this->lang] = $localLanguage[
'default'];
438 if ($this->lang !==
'default' && isset($tempLL[$language])) {
444 return $localLanguage;
456 if ($this->lang !==
'default' && substr($fileRef, -4) ===
'.php') {
458 return substr($fileRef, 0, -4) .
'.' . $this->lang .
'.php';
472 public function overrideLL($index, $value, $overrideDefault =
true)
474 if (!isset(
$GLOBALS[
'LOCAL_LANG'])) {
478 if ($overrideDefault) {
479 $GLOBALS[
'LOCAL_LANG'][
'default'][$index][0][
'target'] = $value;
493 $extraction = array();
494 $labels = array_merge((array)
$GLOBALS[
'LOCAL_LANG'][
'default'], (array)$GLOBALS[
'LOCAL_LANG'][$GLOBALS[
'LANG']->lang]);
496 $labelPattern =
'#^' . preg_quote($prefix,
'#') .
'(' . preg_quote($strip,
'#') .
')?#';
498 foreach ($labels as $label => $value) {
499 if (strpos($label, $prefix) === 0) {
500 $key = preg_replace($labelPattern,
'', $label);
501 $extraction[$key] = $value;