@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | class LanguageFileGenerator implements SingletonInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $template = '<?xml version="1.0" encoding="UTF-8"?> |
|
| 22 | + protected $template = '<?xml version="1.0" encoding="UTF-8"?> |
|
| 23 | 23 | <xliff version="1.0"> |
| 24 | 24 | <file source-language="en" datatype="plaintext" original="messages" date="" product-name="local lang module"> |
| 25 | 25 | <header/> |
@@ -37,58 +37,58 @@ discard block |
||
| 37 | 37 | </file> |
| 38 | 38 | </xliff>'; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $dataType |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function generate($dataType) |
|
| 45 | - { |
|
| 46 | - $label = $dataType; |
|
| 47 | - if (!empty($GLOBALS['TCA'][$dataType]['ctrl']['title'])) { |
|
| 48 | - $label = $this->getLanguageService()->sL($GLOBALS['TCA'][$dataType]['ctrl']['title']); |
|
| 49 | - } |
|
| 40 | + /** |
|
| 41 | + * @param string $dataType |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function generate($dataType) |
|
| 45 | + { |
|
| 46 | + $label = $dataType; |
|
| 47 | + if (!empty($GLOBALS['TCA'][$dataType]['ctrl']['title'])) { |
|
| 48 | + $label = $this->getLanguageService()->sL($GLOBALS['TCA'][$dataType]['ctrl']['title']); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - // Generate language file. |
|
| 52 | - $languageFile = $this->getLanguageFile($dataType); |
|
| 53 | - $content = str_replace('{module_name}', $label, $this->template); |
|
| 54 | - GeneralUtility::writeFileToTypo3tempDir($languageFile, $content); |
|
| 51 | + // Generate language file. |
|
| 52 | + $languageFile = $this->getLanguageFile($dataType); |
|
| 53 | + $content = str_replace('{module_name}', $label, $this->template); |
|
| 54 | + GeneralUtility::writeFileToTypo3tempDir($languageFile, $content); |
|
| 55 | 55 | |
| 56 | - return 'LLL:' . $languageFile; |
|
| 57 | - } |
|
| 56 | + return 'LLL:' . $languageFile; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @param $dataType |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - protected function getLanguageFile($dataType) |
|
| 64 | - { |
|
| 65 | - return $this->getLanguageDirectory() . '/' . $dataType . '.xlf'; |
|
| 66 | - } |
|
| 59 | + /** |
|
| 60 | + * @param $dataType |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + protected function getLanguageFile($dataType) |
|
| 64 | + { |
|
| 65 | + return $this->getLanguageDirectory() . '/' . $dataType . '.xlf'; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @return string |
|
| 70 | - */ |
|
| 71 | - protected function getLanguageDirectory() |
|
| 72 | - { |
|
| 73 | - // Create language file dynamically |
|
| 74 | - $languageDirectory = Environment::getPublicPath() . '/typo3temp/vidi'; |
|
| 75 | - if (!is_dir($languageDirectory)) { |
|
| 76 | - GeneralUtility::mkdir($languageDirectory); |
|
| 77 | - } |
|
| 78 | - return $languageDirectory; |
|
| 79 | - } |
|
| 68 | + /** |
|
| 69 | + * @return string |
|
| 70 | + */ |
|
| 71 | + protected function getLanguageDirectory() |
|
| 72 | + { |
|
| 73 | + // Create language file dynamically |
|
| 74 | + $languageDirectory = Environment::getPublicPath() . '/typo3temp/vidi'; |
|
| 75 | + if (!is_dir($languageDirectory)) { |
|
| 76 | + GeneralUtility::mkdir($languageDirectory); |
|
| 77 | + } |
|
| 78 | + return $languageDirectory; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return \TYPO3\CMS\Core\Localization\LanguageService |
|
| 83 | - */ |
|
| 84 | - protected function getLanguageService() |
|
| 85 | - { |
|
| 86 | - $locale = $GLOBALS['BE_USER']->uc['lang'] ?? ''; |
|
| 87 | - if ($locale === '') { |
|
| 88 | - $locale = 'en'; |
|
| 89 | - } |
|
| 90 | - $languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class); |
|
| 91 | - return $languageServiceFactory->create($locale); |
|
| 92 | - } |
|
| 81 | + /** |
|
| 82 | + * @return \TYPO3\CMS\Core\Localization\LanguageService |
|
| 83 | + */ |
|
| 84 | + protected function getLanguageService() |
|
| 85 | + { |
|
| 86 | + $locale = $GLOBALS['BE_USER']->uc['lang'] ?? ''; |
|
| 87 | + if ($locale === '') { |
|
| 88 | + $locale = 'en'; |
|
| 89 | + } |
|
| 90 | + $languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class); |
|
| 91 | + return $languageServiceFactory->create($locale); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |