diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-65698-AdditionalResourceServiceLocalization.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-65698-AdditionalResourceServiceLocalization.rst new file mode 100644 index 0000000000000000000000000000000000000000..0026e48c3dd2a67259e82e64a7aa0658ed66aa95 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-65698-AdditionalResourceServiceLocalization.rst @@ -0,0 +1,17 @@ +=========================================================================== +Feature: #65698 - Additional localization files in backend workspace module +=========================================================================== + +Description +=========== + +The AdditionalResourceService of the workspace module in the backend is extended +by the functionality to register custom localization files that are forwarded to +the PageRenderer in the end. This way, labels can be accessed in JavaScript using +the TYPO3.l10n.localize() function for instance. + +.. code-block:: php + + \TYPO3\CMS\Workspaces\Service\AdditionalResourceService::getInstance()->addLocalizationResource( + 'EXT:my_extension/Resources/Private/Language/locallang.xlf' + ); diff --git a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php index 5bc30bd49f36d354a38e3f069b676c3c94cffab4..2d3f3e2027720ca5acbbbbbc39bfe55f3e813f58 100644 --- a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php +++ b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php @@ -192,6 +192,9 @@ class ReviewController extends AbstractController { foreach ($javaScriptFiles as $javaScriptFile) { $this->pageRenderer->addJsFile($javaScriptFile); } + foreach ($this->getAdditionalResourceService()->getLocalizationResources() as $localizationResource) { + $this->pageRenderer->addInlineLanguageLabelFile($localizationResource); + } $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history')); } diff --git a/typo3/sysext/workspaces/Classes/Service/AdditionalResourceService.php b/typo3/sysext/workspaces/Classes/Service/AdditionalResourceService.php index 2504d150c21dd47678dfbd3e944c39dadfbd8efa..d81197dec064b7c25334279954d47bf4057d7ef6 100644 --- a/typo3/sysext/workspaces/Classes/Service/AdditionalResourceService.php +++ b/typo3/sysext/workspaces/Classes/Service/AdditionalResourceService.php @@ -14,6 +14,8 @@ namespace TYPO3\CMS\Workspaces\Service; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Utility\GeneralUtility; + /** * Service for additional columns in GridPanel * @@ -31,6 +33,11 @@ class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface { */ protected $stylesheetResources = array(); + /** + * @var array + */ + protected $localizationResources = array(); + /** * @return \TYPO3\CMS\Workspaces\Service\AdditionalResourceService */ @@ -42,7 +49,7 @@ class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface { * @return \TYPO3\CMS\Extbase\Object\ObjectManager */ static public function getObjectManager() { - return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); + return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); } /** @@ -63,6 +70,15 @@ class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface { $this->stylesheetResources[$name] = $this->resolvePath($resourcePath); } + /** + * @param string $resourcePath + * @return void + */ + public function addLocalizationResource($resourcePath) { + $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath); + $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath; + } + /** * @return array */ @@ -77,6 +93,13 @@ class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface { return $this->stylesheetResources; } + /** + * @return array + */ + public function getLocalizationResources() { + return $this->localizationResources; + } + /** * Resolve path * @@ -84,7 +107,7 @@ class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface { * @return NULL|string */ protected function resolvePath($resourcePath) { - $absoluteFilePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($resourcePath); + $absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath); $absolutePath = dirname($absoluteFilePath); $fileName = basename($absoluteFilePath);