Commit 3adecebc authored by Pawel Cieslik's avatar Pawel Cieslik Committed by Benni Mack
Browse files

[!!!][TASK] Remove TYPO3.LLL usages in TYPO3 core

Remove TYPO3.LLL after moving to new JS API for translations TYPO3.lang

Resolves: #83161
Releases: master
Change-Id: I815b15349c8bfe6ca71f4d1ce59b7b01e670eae2
Reviewed-on: https://review.typo3.org/54860


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent bf9b0e27
......@@ -109,6 +109,7 @@ class BackendController
public function __construct()
{
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
$this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
......@@ -124,7 +125,6 @@ class BackendController
$this->pageRenderer->addExtDirectCode();
// Add default BE javascript
$this->jsFiles = [
'locallang' => $this->getLocalLangFileName(),
'md5' => 'EXT:backend/Resources/Public/JavaScript/md5.js',
'evalfield' => 'EXT:backend/Resources/Public/JavaScript/jsfunc.evalfield.js',
'backend' => 'EXT:backend/Resources/Public/JavaScript/backend.js',
......@@ -499,119 +499,6 @@ class BackendController
return implode(LF, $toolbar);
}
/**
* Returns the file name to the LLL JavaScript, containing the localized labels,
* which can be used in JavaScript code.
*
* @return string File name of the JS file, relative to TYPO3_mainDir
* @throws \RuntimeException
*/
protected function getLocalLangFileName()
{
$code = $this->generateLocalLang();
$filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js';
if (!file_exists(PATH_site . $filePath)) {
// writeFileToTypo3tempDir() returns NULL on success (please double-read!)
$error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code);
if ($error !== null) {
throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1295193026);
}
}
return '../' . $filePath;
}
/**
* Reads labels required in JavaScript code from the localization system and returns them as JSON
* array in TYPO3.LLL.
*
* @return string JavaScript code containing the LLL labels in TYPO3.LLL
*/
protected function generateLocalLang()
{
$lang = $this->getLanguageService();
$coreLabels = [
'waitTitle' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_logging_in'),
'refresh_login_failed' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_failed'),
'refresh_login_failed_message' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_failed_message'),
'refresh_login_title' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_title'),
'login_expired' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_expired'),
'refresh_login_username' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_username'),
'refresh_login_password' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_password'),
'refresh_login_emptyPassword' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_emptyPassword'),
'refresh_login_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_button'),
'refresh_exit_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_exit_button'),
'please_wait' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.please_wait'),
'be_locked' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.be_locked'),
'login_about_to_expire' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_about_to_expire'),
'login_about_to_expire_title' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_about_to_expire_title'),
'refresh_login_logout_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_logout_button'),
'refresh_login_refresh_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_refresh_button'),
'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading')
];
$labels = [
'fileUpload' => [
'windowTitle',
'buttonSelectFiles',
'buttonCancelAll',
'infoComponentMaxFileSize',
'infoComponentFileUploadLimit',
'infoComponentFileTypeLimit',
'infoComponentOverrideFiles',
'processRunning',
'uploadWait',
'uploadStarting',
'uploadProgress',
'uploadSuccess',
'errorQueueLimitExceeded',
'errorQueueFileSizeLimit',
'errorQueueZeroByteFile',
'errorQueueInvalidFiletype',
'errorUploadHttp',
'errorUploadMissingUrl',
'errorUploadIO',
'errorUploadSecurityError',
'errorUploadLimit',
'errorUploadFailed',
'errorUploadFileIDNotFound',
'errorUploadFileValidation',
'errorUploadFileCancelled',
'errorUploadStopped',
'allErrorMessageTitle',
'allErrorMessageText',
'allError401',
'allError2038'
],
'liveSearch' => [
'title',
'helpTitle',
'emptyText',
'loadingText',
'listEmptyText',
'showAllResults',
'helpDescription',
'helpDescriptionPages',
'helpDescriptionContent'
],
'viewPort' => [
'tooltipModuleMenuSplit',
'tooltipNavigationContainerSplitDrag',
'tooltipNavigationContainerSplitClick',
'tooltipDebugPanelSplitDrag'
]
];
$generatedLabels = [];
$generatedLabels['core'] = $coreLabels;
// First loop over all categories (fileUpload, liveSearch, ..)
foreach ($labels as $categoryName => $categoryLabels) {
// Then loop over every single label
foreach ($categoryLabels as $label) {
// LLL identifier must be called $categoryName_$label, e.g. liveSearch_loadingText
$generatedLabels[$categoryName][$label] = $this->getLanguageService()->getLL($categoryName . '_' . $label);
}
}
return 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';';
}
/**
* Generates the JavaScript code for the backend.
*/
......
.. include:: ../../Includes.txt
========================================================
Breaking: #83161 - Remove TYPO3.LLL usages in TYPO3 core
========================================================
See :issue:`83161`
Description
===========
After moving to the :js:`TYPO3.lang` API for javascript, the :js:`TYPO3.LLL` is not needed anymore.
Impact
======
All extensions which are using :js:`TYPO3.LLL` for translation in javascript should be checked and updated accordingly.
Affected Installations
======================
Any installation using extensions, which are using :js:`TYPO3.LLL`.
Migration
=========
Use :js:`TYPO3.lang['label']` from javascript. To make custom language labels available in javascript,
add :php:`$this->pageRenderer->addInlineLanguageLabelFile('EXT:foo/Resources/Private/Language/locallang.xlf');`
in your backend controller.
The class typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php was removed, so if you used it in your code you have to remove the dependency.
.. index:: Backend, JavaScript, PHP-API, NotScanned
<?php
namespace TYPO3\CMS\Feedit;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Controller\EditDocumentController;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class FrontendEditAssetLoader
*/
class FrontendEditAssetLoader
{
/**
* @param EditDocumentController $controller
*/
public function attachAssets(EditDocumentController $controller)
{
if ((int)GeneralUtility::_GP('feEdit') === 1) {
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
// We have to load some locallang strings and push them into TYPO3.LLL if this request was
// triggered by feedit. Originally, this object is fed by BackendController which is not
// called here. This block of code is intended to be removed at a later point again.
$lang = $this->getLanguageService();
$coreLabels = [
'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading')
];
$generatedLabels = [];
$generatedLabels['core'] = $coreLabels;
$code = 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';';
$filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js';
if (!file_exists(PATH_site . $filePath)) {
// writeFileToTypo3tempDir() returns NULL on success (please double-read!)
$error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code);
if ($error !== null) {
throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1446118286);
}
}
$pageRenderer->addJsFile('../' . $filePath);
}
}
/**
* Returns LanguageService
*
* @return \TYPO3\CMS\Core\Localization\LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
......@@ -3,10 +3,3 @@ defined('TYPO3_MODE') or die();
// Register the edit panel view.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class;
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect(
\TYPO3\CMS\Backend\Controller\EditDocumentController::class,
'initAfter',
\TYPO3\CMS\Feedit\FrontendEditAssetLoader::class,
'attachAssets'
);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment