2 namespace TYPO3\CMS\Core\Localization;
65 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'format'][
'priority']) && trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'format'][
'priority']) !==
'') {
68 $this->supportedExtensions = array(
'xlf',
'xml',
'php');
79 public function hasData($fileReference, $languageKey)
81 if (isset($this->data[$fileReference][$languageKey]) && is_array($this->data[$fileReference][$languageKey])) {
97 return $this->data[$fileReference];
110 return $this->data[$fileReference][$languageKey];
123 $this->data[$fileReference][$languageKey] =
$data;
135 unset($this->data[$fileReference]);
151 $this->configuration[$fileReference] = array(
152 'fileReference' => $fileReference,
153 'fileExtension' =>
false,
154 'parserClass' => null,
155 'languageKey' => $languageKey,
156 'charset' => $charset
159 foreach ($this->supportedExtensions as $extension) {
160 if (@is_file(($fileWithoutExtension .
'.' . $extension))) {
161 $this->configuration[$fileReference][
'fileReference'] = $fileWithoutExtension .
'.' . $extension;
162 $this->configuration[$fileReference][
'fileExtension'] = $extension;
166 if ($this->configuration[$fileReference][
'fileExtension'] ===
false) {
167 throw new FileNotFoundException(sprintf(
'Source localization file (%s) not found', $fileReference), 1306410755);
169 $extension = $this->configuration[$fileReference][
'fileExtension'];
170 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension]) && trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension]) !==
'') {
171 $this->configuration[$fileReference][
'parserClass'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension];
173 throw new InvalidParserException(
'TYPO3 Fatal Error: l10n parser for file extension "' . $extension .
'" is not configured! Please check you configuration.', 1301579637);
175 if (!class_exists($this->configuration[$fileReference][
'parserClass']) || trim($this->configuration[$fileReference][
'parserClass']) ===
'') {
176 throw new InvalidParserException(
'TYPO3 Fatal Error: l10n parser "' . $this->configuration[$fileReference][
'parserClass'] .
'" cannot be found or is an empty parser!', 1270853900);
189 if (!isset($this->configuration[$fileReference][
'fileReferenceWithoutExtension'])) {
190 $this->configuration[$fileReference][
'fileReferenceWithoutExtension'] = preg_replace(
'/\\.[a-z0-9]+$/i',
'', $fileReference);
192 return $this->configuration[$fileReference][
'fileReferenceWithoutExtension'];
204 if (isset($this->configuration[$fileReference][
'parserClass']) && trim($this->configuration[$fileReference][
'parserClass']) !==
'') {
207 throw new InvalidParserException(sprintf(
'Invalid parser configuration for the current file (%s)', $fileReference), 1307293692);
220 if (isset($this->configuration[$fileReference][
'fileReference']) && trim($this->configuration[$fileReference][
'fileReference']) !==
'') {
221 return (
string)$this->configuration[$fileReference][
'fileReference'];
223 throw new \InvalidArgumentException(sprintf(
'Invalid file reference configuration for the current file (%s)', $fileReference), 1307293693);