Ejemplo n.º 1
0
 /**
  * Overwrites pi_loadLL() to handle custom location of language files.
  *
  * Loads local-language values by looking for a "locallang" file in the
  * plugin class directory ($this->scriptRelPath) and if found includes it.
  * Also locallang values set in the TypoScript property "_LOCAL_LANG" are
  * merged onto the values found in the "locallang" file.
  * Supported file extensions xlf, xml, php
  *
  * @param string $languageFilePath path to the plugin language file in format EXT:....
  * @return void
  */
 public function pi_loadLL($languageFilePath = '')
 {
     if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) {
         $pathElements = pathinfo($this->scriptRelPath);
         $languageFileName = $pathElements['filename'];
         $basePath = 'EXT:' . $this->extKey . '/Resources/Private/Language/locallang.xlf';
         // Read the strings in the required charset (since TYPO3 4.2)
         $this->LOCAL_LANG = $this->languageFactory->getParsedData($basePath, $this->LLkey, $GLOBALS['TSFE']->renderCharset, 3);
         $alternativeLanguageKeys = GeneralUtility::trimExplode(',', $this->altLLkey, true);
         foreach ($alternativeLanguageKeys as $languageKey) {
             $tempLL = $this->languageFactory->getParsedData($basePath, $languageKey, $GLOBALS['TSFE']->renderCharset, 3);
             if ($this->LLkey !== 'default' && isset($tempLL[$languageKey])) {
                 $this->LOCAL_LANG[$languageKey] = $tempLL[$languageKey];
             }
         }
         // Overlaying labels from TypoScript (including fictitious language keys for non-system languages!):
         $translationInTypoScript = $this->typoScriptConfiguration->getLocalLangConfiguration();
         if (count($translationInTypoScript) == 0) {
             return;
         }
         // Clear the "unset memory"
         $this->LOCAL_LANG_UNSET = array();
         foreach ($translationInTypoScript as $languageKey => $languageArray) {
             // Remove the dot after the language key
             $languageKey = substr($languageKey, 0, -1);
             // Don't process label if the language is not loaded
             if (is_array($languageArray) && isset($this->LOCAL_LANG[$languageKey])) {
                 foreach ($languageArray as $labelKey => $labelValue) {
                     if (!is_array($labelValue)) {
                         $this->LOCAL_LANG[$languageKey][$labelKey][0]['target'] = $labelValue;
                         $this->LOCAL_LANG_charset[$languageKey][$labelKey] = 'utf-8';
                         if ($labelValue === '') {
                             $this->LOCAL_LANG_UNSET[$languageKey][$labelKey] = '';
                         }
                     }
                 }
             }
         }
     }
     $this->LOCAL_LANG_loaded = 1;
 }