From 3360fec8e0f99dc72ef11b930c60e16ff059c0b2 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Fri, 2 Dec 2016 20:23:30 +0100 Subject: [PATCH] [FEATURE] Purge language packs in language module A "remove" button is added to the list of the installed languages. Resolves: #58637 Releases: master Change-Id: Ibd8911d2c58e449a026f52f4bd8b0b2d04bc2bbf Reviewed-on: https://review.typo3.org/50860 Reviewed-by: Markus Sommer <markussom@posteo.de> Tested-by: Markus Sommer <markussom@posteo.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Susanne Moog <susanne.moog@typo3.org> Tested-by: Susanne Moog <susanne.moog@typo3.org> --- .../Public/Less/TYPO3/_module_lang.less | 2 ++ .../backend/Resources/Public/Css/backend.css | 5 +++ ...637-PurgeLanguagePacksInLanguageModule.rst | 22 +++++++++++++ .../Classes/Controller/LanguageController.php | 18 +++++++++++ .../View/Language/RemoveLanguageJson.php | 31 +++++++++++++++++++ .../Resources/Private/Language/locallang.xlf | 3 ++ .../Resources/Private/Layouts/Default.html | 1 + .../Templates/Language/ListLanguages.html | 10 ++++-- .../Public/JavaScript/LanguageModule.js | 31 ++++++++++++++++++- typo3/sysext/lang/ext_tables.php | 2 +- 10 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst create mode 100644 typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php diff --git a/Build/Resources/Public/Less/TYPO3/_module_lang.less b/Build/Resources/Public/Less/TYPO3/_module_lang.less index c1a1518f044f..27497105dac7 100644 --- a/Build/Resources/Public/Less/TYPO3/_module_lang.less +++ b/Build/Resources/Public/Less/TYPO3/_module_lang.less @@ -27,6 +27,7 @@ div.typo3-module-lang { a { &.deactivateLanguageLink, + &.removeLanguageLink, &.updateLanguageLink, &.updateTranslationLink { display: none; @@ -70,6 +71,7 @@ div.typo3-module-lang { tr.complete, td.complete { a { + &.removeLanguageLink, &.updateLanguageLink, &.updateTranslationLink { display: none; diff --git a/typo3/sysext/backend/Resources/Public/Css/backend.css b/typo3/sysext/backend/Resources/Public/Css/backend.css index 2489c50d4f5a..5fcbd52b6ad9 100644 --- a/typo3/sysext/backend/Resources/Public/Css/backend.css +++ b/typo3/sysext/backend/Resources/Public/Css/backend.css @@ -13701,6 +13701,7 @@ div.typo3-module-lang table.t3-datatable tr.disabled { color: #aaaaaa; } div.typo3-module-lang table.t3-datatable tr.disabled a.deactivateLanguageLink, +div.typo3-module-lang table.t3-datatable tr.disabled a.removeLanguageLink, div.typo3-module-lang table.t3-datatable tr.disabled a.updateLanguageLink, div.typo3-module-lang table.t3-datatable tr.disabled a.updateTranslationLink { display: none; @@ -13726,6 +13727,10 @@ div.typo3-module-lang table.t3-datatable tr.complete div.progressBar { display: inline; cursor: default; } +div.typo3-module-lang table.t3-datatable tr.processing a.removeLanguageLink, +div.typo3-module-lang table.t3-datatable td.processing a.removeLanguageLink, +div.typo3-module-lang table.t3-datatable tr.complete a.removeLanguageLink, +div.typo3-module-lang table.t3-datatable td.complete a.removeLanguageLink, div.typo3-module-lang table.t3-datatable tr.processing a.updateLanguageLink, div.typo3-module-lang table.t3-datatable td.processing a.updateLanguageLink, div.typo3-module-lang table.t3-datatable tr.complete a.updateLanguageLink, diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst new file mode 100644 index 000000000000..4f4a3542902f --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst @@ -0,0 +1,22 @@ +.. include:: ../../Includes.txt + +========================================================= +Feature: #58637 - Purge language packs in language module +========================================================= + +See :issue:`58637` + +Description +=========== + +The language module in the backend offers the possibility to activate and deactivate language packs. +If deactivating a language pack that previously has been loaded, the data stays in typo3conf/l10n/<locale>/ . +A remove button is added to the actions. With the remove action the language is disabled and the data is removed from the typo3conf/l10n/<locale>/ directory. + + +Impact +====== + +The language data can now be removed from the installation. + +.. index:: Backend \ No newline at end of file diff --git a/typo3/sysext/lang/Classes/Controller/LanguageController.php b/typo3/sysext/lang/Classes/Controller/LanguageController.php index c75cc16479fb..c183bd3abe66 100644 --- a/typo3/sysext/lang/Classes/Controller/LanguageController.php +++ b/typo3/sysext/lang/Classes/Controller/LanguageController.php @@ -238,6 +238,23 @@ class LanguageController extends ActionController $this->view->assign('response', $response); } + /** + * Remove a language + * + * @param array $data The request data + * @return void + */ + public function removeLanguageAction(array $data) + { + $response = ['success' => false]; + if (!empty($data['locale'])) { + $response = $this->languageRepository->deactivateByLocale($data['locale']); + $absoluteLanguagePath = GeneralUtility::getFileAbsFileName(PATH_typo3conf . 'l10n/' . $data['locale']); + GeneralUtility::rmdir($absoluteLanguagePath, true); + } + $this->view->assign('response', $response); + } + /** * DocHeaderMenu */ @@ -258,6 +275,7 @@ class LanguageController extends ActionController 'flashmessage.canceled', 'flashmessage.languageActivated', 'flashmessage.languageDeactivated', + 'flashmessage.languageRemoved', 'flashmessage.noLanguageActivated', 'flashmessage.errorOccurred', 'table.processing', diff --git a/typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php b/typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php new file mode 100644 index 000000000000..29e2d540cc73 --- /dev/null +++ b/typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php @@ -0,0 +1,31 @@ +<?php +namespace TYPO3\CMS\Lang\View\Language; + +/* + * 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! + */ + +/** + * JSON view for "removeLanguage" action in "Language" controller + */ +class RemoveLanguageJson extends \TYPO3\CMS\Lang\View\AbstractJsonView +{ + /** + * Returns the response data + * + * @return array The response data + */ + protected function getReponseData() + { + return $this->variables['response']; + } +} diff --git a/typo3/sysext/lang/Resources/Private/Language/locallang.xlf b/typo3/sysext/lang/Resources/Private/Language/locallang.xlf index be05d3f1cfbf..c74c635effb4 100644 --- a/typo3/sysext/lang/Resources/Private/Language/locallang.xlf +++ b/typo3/sysext/lang/Resources/Private/Language/locallang.xlf @@ -59,6 +59,9 @@ <trans-unit id="flashmessage.languageDeactivated"> <source>Language was successfully deactivated.</source> </trans-unit> + <trans-unit id="flashmessage.languageRemoved"> + <source>Language was successfully deactivated and removed.</source> + </trans-unit> <trans-unit id="flashmessage.errorOccurred"> <source>The request has failed.</source> </trans-unit> diff --git a/typo3/sysext/lang/Resources/Private/Layouts/Default.html b/typo3/sysext/lang/Resources/Private/Layouts/Default.html index 24bb1924f71c..29271a2f890f 100644 --- a/typo3/sysext/lang/Resources/Private/Layouts/Default.html +++ b/typo3/sysext/lang/Resources/Private/Layouts/Default.html @@ -5,6 +5,7 @@ data-update-translation-uri="{f:uri.action(action:'updateTranslation',format:'json')}" data-activate-language-uri="{f:uri.action(action:'activateLanguage',format:'json')}" data-deactivate-language-uri="{f:uri.action(action:'deactivateLanguage',format:'json')}" + data-remove-language-uri="{f:uri.action(action:'removeLanguage',format:'json')}" data-prefix="tx_lang_tools_langlanguage" > diff --git a/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html b/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html index d72bca7f6d89..219f12bcba12 100644 --- a/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html +++ b/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html @@ -58,9 +58,13 @@ </td> <td class="actions"> <a class="btn btn-default updateLanguageLink" data-action="updateLanguage" - data-locale="{language.locale}" data-language="{language.label}" data-selected="true"><span - title="Download" class="t3-icon fa fa-download"> </span></a> - + data-locale="{language.locale}" data-language="{language.label}" data-selected="true"> + <span title="Download" class="t3-icon fa fa-download"> </span> + </a> + <a class="btn btn-default removeLanguageLink" data-action="removeLanguage" + data-locale="{language.locale}" data-language="{language.label}" data-selected="true"> + <span title="Remove" class="t3-icon fa fa-trash"> </span> + </a> <div class="progressBar"> <div class="progress"> <div class="progress-text"></div> diff --git a/typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js b/typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js index 4e1de2ca11a3..e8f95558d768 100644 --- a/typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js +++ b/typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js @@ -49,6 +49,7 @@ define(['jquery', activateIcon: 'span.activateIcon', deactivateIcon: 'span.deactivateIcon', downloadIcon: 'span.downloadIcon', + removeIcon: 'span.removeIcon', loadingIcon: 'span.loadingIcon', completeIcon: 'span.completeIcon', progressBar: 'div.progressBar', @@ -152,6 +153,31 @@ define(['jquery', }); }; + /** + * Remove a language + * + * @param {HTMLElement} triggerElement + * @param {Object} parameters + */ + LanguageModule.removeLanguageAction = function(triggerElement, parameters) { + var $row = $(triggerElement).closest('tr'), + locale = $row.data('locale'), + $lastUpdate = $(LanguageModule.identifiers.lastUpdate, $row); + + if ($row.hasClass(LanguageModule.classes.processing)) { + LanguageModule.abortAjaxRequest(); + } + LanguageModule.executeAjaxRequest(LanguageModule.settings.removeLanguageUri, {locale: locale}, function(response, status) { + if (status === 'success' && response.success) { + $row.removeClass(LanguageModule.classes.enabled).removeClass(LanguageModule.classes.complete).addClass(LanguageModule.classes.disabled); + $lastUpdate.html(''); + LanguageModule.displaySuccess(LanguageModule.labels.languageRemoved); + } else { + LanguageModule.displayError(LanguageModule.labels.errorOccurred); + } + }); + }; + /** * Update a language * @@ -261,6 +287,7 @@ define(['jquery', activate: $(LanguageModule.identifiers.activateIcon, LanguageModule.context).html(), deactivate: $(LanguageModule.identifiers.deactivateIcon, LanguageModule.context).html(), download: $(LanguageModule.identifiers.downloadIcon, LanguageModule.context).html(), + remove: $(LanguageModule.identifiers.removeIcon, LanguageModule.context).html(), loading: $(LanguageModule.identifiers.loadingIcon, LanguageModule.context).html(), complete: $(LanguageModule.identifiers.completeIcon, LanguageModule.context).html(), progressBar: $(LanguageModule.identifiers.progressBar, LanguageModule.context).html() @@ -270,7 +297,7 @@ define(['jquery', /** * Build labels * - * @returns {{processing: *, search: *, loadingRecords: *, zeroRecords: *, emptyTable: *, dateFormat: *, errorHeader: *, infoHeader: *, successHeader: *, languageActivated: *, errorOccurred: *, languageDeactivated: *, updateComplete: *}} + * @returns {{processing: *, search: *, loadingRecords: *, zeroRecords: *, emptyTable: *, dateFormat: *, errorHeader: *, infoHeader: *, successHeader: *, languageActivated: *, errorOccurred: *, languageDeactivated: *, languageRemoved: *, updateComplete: *}} */ LanguageModule.buildLabels = function() { return { @@ -286,6 +313,7 @@ define(['jquery', languageActivated: TYPO3.lang['flashmessage.languageActivated'], errorOccurred: TYPO3.lang['flashmessage.errorOccurred'], languageDeactivated: TYPO3.lang['flashmessage.languageDeactivated'], + languageRemoved: TYPO3.lang['flashmessage.languageRemoved'], noLanguageActivated: TYPO3.lang['flashmessage.noLanguageActivated'], updateComplete: TYPO3.lang['flashmessage.updateComplete'], canceled: TYPO3.lang['flashmessage.canceled'] @@ -341,6 +369,7 @@ define(['jquery', render: function(data, type, row) { var links = [ LanguageModule.buildActionLink('updateTranslation', data, LanguageModule.icons.download), + LanguageModule.buildActionLink('removeTranslation', data, LanguageModule.icons.remove), LanguageModule.buildLoadingIndicator(), LanguageModule.buildCompleteIndicator() ]; diff --git a/typo3/sysext/lang/ext_tables.php b/typo3/sysext/lang/ext_tables.php index f9514baac48a..c8dafb1d7496 100644 --- a/typo3/sysext/lang/ext_tables.php +++ b/typo3/sysext/lang/ext_tables.php @@ -10,7 +10,7 @@ if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { 'language', 'after:extensionmanager', [ - 'Language' => 'listLanguages, listTranslations, getTranslations, updateLanguage, updateTranslation, activateLanguage, deactivateLanguage', + 'Language' => 'listLanguages, listTranslations, getTranslations, updateLanguage, updateTranslation, activateLanguage, deactivateLanguage, removeLanguage', ], [ 'access' => 'admin', -- GitLab