Skip to content

Commit a5a4eed

Browse files
committed
[BUGFIX] Make copy mode work again
The newly added structure with LocalizationModes registered as configurable modes through PHP instead of the hard-coded Localization used the `LocalizationController::ACTION_*` constants for detecting the EventListener being responsible for a translation mode. As the JavaScript identifier was taken for the comparison and the identifier was named `copy`, but the compare-to is named `copyFromLanguage`, the condition skipped the EventListener instead of building the command map for the DataHandler to work. Fixes #11
1 parent 72ab659 commit a5a4eed

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Classes/EventListener/ProvideDefaultTypo3LocalizationModesEventListener.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace WebVision\Deepl\Base\EventListener;
66

7+
use TYPO3\CMS\Backend\Controller\Page\LocalizationController;
78
use TYPO3\CMS\Core\Utility\MathUtility;
89
use WebVision\Deepl\Base\Event\GetLocalizationModesEvent;
910
use WebVision\Deepl\Base\Localization\LocalizationMode;
@@ -24,22 +25,22 @@ public function __invoke(GetLocalizationModesEvent $event): void
2425
$modes = [];
2526
if ($this->allowTranslate($event)) {
2627
$modes[] = new LocalizationMode(
27-
identifier: 'localize',
28+
identifier: LocalizationController::ACTION_LOCALIZE,
2829
title: $event->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.translate'),
2930
description: $event->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.translate'),
3031
icon: 'actions-localize',
31-
before: ['copy'],
32+
before: [LocalizationController::ACTION_COPY],
3233
after: [],
3334
);
3435
}
3536
if ($this->allowCopy($event)) {
3637
$modes[] = new LocalizationMode(
37-
identifier: 'copy',
38+
identifier: LocalizationController::ACTION_COPY,
3839
title: $event->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.copy'),
3940
description: $event->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.copy'),
4041
icon: 'actions-edit-copy',
4142
before: [],
42-
after: ['localize'],
43+
after: [LocalizationController::ACTION_LOCALIZE],
4344
);
4445
}
4546

Tests/Functional/Controller/Backend/LocalizationControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public static function dispatchGetLocalizationModesEventReturnsExpectedDefaultMo
7979
'title' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.translate',
8080
'description' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.translate',
8181
'icon' => 'actions-localize',
82-
'before' => ['copy'],
82+
'before' => ['copyFromLanguage'],
8383
'after' => [],
8484
'restrictedSourceLanguageIds' => null,
8585
],
8686
[
87-
'identifier' => 'copy',
87+
'identifier' => 'copyFromLanguage',
8888
'title' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.copy',
8989
'description' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.copy',
9090
'icon' => 'actions-edit-copy',
@@ -114,7 +114,7 @@ public static function dispatchGetLocalizationModesEventReturnsExpectedDefaultMo
114114
'title' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.translate',
115115
'description' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.translate',
116116
'icon' => 'actions-localize',
117-
'before' => ['copy'],
117+
'before' => ['copyFromLanguage'],
118118
'after' => [],
119119
'restrictedSourceLanguageIds' => null,
120120
],
@@ -128,7 +128,7 @@ public static function dispatchGetLocalizationModesEventReturnsExpectedDefaultMo
128128
'expectedModesJsonString' => \json_encode(
129129
[
130130
[
131-
'identifier' => 'copy',
131+
'identifier' => 'copyFromLanguage',
132132
'title' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.copy',
133133
'description' => 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.educate.copy',
134134
'icon' => 'actions-edit-copy',

0 commit comments

Comments
 (0)