64 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'format'][
'priority']) && trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'format'][
'priority']) !==
'') {
65 $this->supportedExtensions = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'format'][
'priority']);
67 $this->supportedExtensions = [
'xlf',
'xml'];
78 public function hasData($fileReference, $languageKey)
80 if (isset($this->data[$fileReference][$languageKey]) && is_array($this->data[$fileReference][$languageKey])) {
94 public function getData($fileReference)
96 return $this->data[$fileReference];
109 return $this->data[$fileReference][$languageKey] ?? [];
122 $this->data[$fileReference][$languageKey] =
$data;
134 unset($this->data[$fileReference]);
149 $this->configuration[$fileReference] = [
150 'fileReference' => $fileReference,
151 'fileExtension' =>
false,
152 'parserClass' =>
null,
153 'languageKey' => $languageKey
156 foreach ($this->supportedExtensions as $extension) {
157 if (@is_file($fileWithoutExtension .
'.' . $extension)) {
158 $this->configuration[$fileReference][
'fileReference'] = $fileWithoutExtension .
'.' . $extension;
159 $this->configuration[$fileReference][
'fileExtension'] = $extension;
163 if ($this->configuration[$fileReference][
'fileExtension'] ===
false) {
164 throw new FileNotFoundException(sprintf(
'Source localization file (%s) not found', $fileReference), 1306410755);
166 $extension = $this->configuration[$fileReference][
'fileExtension'];
167 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension]) && trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension]) !==
'') {
168 $this->configuration[$fileReference][
'parserClass'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'lang'][
'parser'][$extension];
170 throw new InvalidParserException(
'TYPO3 Fatal Error: l10n parser for file extension "' . $extension .
'" is not configured! Please check you configuration.', 1301579637);
172 if (!class_exists($this->configuration[$fileReference][
'parserClass']) || trim($this->configuration[$fileReference][
'parserClass']) ===
'') {
173 throw new InvalidParserException(
'TYPO3 Fatal Error: l10n parser "' . $this->configuration[$fileReference][
'parserClass'] .
'" cannot be found or is an empty parser!', 1270853900);
186 if (!isset($this->configuration[$fileReference][
'fileReferenceWithoutExtension'])) {
187 $this->configuration[$fileReference][
'fileReferenceWithoutExtension'] = preg_replace(
'/\\.[a-z0-9]+$/i',
'', $fileReference);
189 return $this->configuration[$fileReference][
'fileReferenceWithoutExtension'];
201 if (isset($this->configuration[$fileReference][
'parserClass']) && trim($this->configuration[$fileReference][
'parserClass']) !==
'') {
202 return GeneralUtility::makeInstance((
string)$this->configuration[$fileReference][
'parserClass']);
204 throw new InvalidParserException(sprintf(
'Invalid parser configuration for the current file (%s)', $fileReference), 1307293692);
216 if (isset($this->configuration[$fileReference][
'fileReference']) && trim($this->configuration[$fileReference][
'fileReference']) !==
'') {
217 return (
string)$this->configuration[$fileReference][
'fileReference'];
219 throw new \InvalidArgumentException(sprintf(
'Invalid file reference configuration for the current file (%s)', $fileReference), 1307293693);