From b902b2d7820f17048b7472c03f81998d981f4eb4 Mon Sep 17 00:00:00 2001 From: pKallert <91674611+pKallert@users.noreply.github.com> Date: Thu, 25 Jan 2024 08:17:06 +0100 Subject: [PATCH 1/2] Task: translate backend messages --- .../Controller/BackendServiceController.php | 32 ++++++++++++------- Classes/Controller/TranslationTrait.php | 4 +-- Resources/Private/Translations/en/Main.xlf | 11 +++++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index ab9715a03a..4b6b0e6543 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -165,7 +165,9 @@ public function changeAction(array $changes): void $changes->apply(); $success = new Info(); - $success->setMessage(sprintf('%d change(s) successfully applied.', $count)); + $success->setMessage( + $this->getLabel('changesApplied', [$count], $count) + ); $this->feedbackCollection->add($success); } catch (\Exception $e) { @@ -191,7 +193,9 @@ public function publishAllAction(): void $this->publishingService->publishWorkspace($contentRepository, $workspaceName); $success = new Success(); - $success->setMessage(sprintf('Published.')); + $success->setMessage( + $this->getLabel('publishedAllChanges', ['workspaceName' => $workspaceName]) + ); $updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName); $this->feedbackCollection->add($success); @@ -238,11 +242,10 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa } $success = new Success(); - $success->setMessage(sprintf( - 'Published %d change(s) to %s.', - count($nodeContextPaths), - $targetWorkspaceName - )); + $changesCount = count($nodeContextPaths); + $success->setMessage( + $this->getLabel('changesPublished', [$changesCount,$targetWorkspaceName], $changesCount) + ); $updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName); $this->feedbackCollection->add($success); @@ -295,7 +298,10 @@ public function discardAction(array $nodeContextPaths): void $contentRepository->handle($command)->block(); $success = new Success(); - $success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths))); + $changesCount = count($nodeContextPaths); + $success->setMessage( + $this->getLabel('changesDiscarded', [$changesCount], $changesCount) + ); $updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName); $this->feedbackCollection->add($success); @@ -339,9 +345,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d $contentRepository->handle($command)->block(); } catch (WorkspaceIsNotEmptyException $exception) { $error = new Error(); - $error->setMessage('Your personal workspace currently contains unpublished changes.' - . ' In order to switch to a different target workspace you need to either publish' - . ' or discard pending changes first.'); + $error->setMessage( + $this->getLabel('workspaceContainsUnpublishedChanges') + ); $this->feedbackCollection->add($error); $this->view->assign('value', $this->feedbackCollection); @@ -365,7 +371,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d $documentNode = $subgraph->findNodeById($nodeAddress->nodeAggregateId); $success = new Success(); - $success->setMessage(sprintf('Switched base workspace to %s.', $targetWorkspaceName)); + $success->setMessage( + $this->getLabel('switchedBaseWorkspace', ['workspace' => $targetWorkspaceName]) + ); $this->feedbackCollection->add($success); $updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $userWorkspaceName); diff --git a/Classes/Controller/TranslationTrait.php b/Classes/Controller/TranslationTrait.php index fb353f51fe..a83df525c7 100644 --- a/Classes/Controller/TranslationTrait.php +++ b/Classes/Controller/TranslationTrait.php @@ -28,12 +28,12 @@ trait TranslationTrait /** * @param array $arguments */ - public function getLabel(string $id, array $arguments = []): string + public function getLabel(string $id, array $arguments = [], ?int $quantity=null): string { return $this->translator->translateById( $id, $arguments, - null, + $quantity, null, 'Main', 'Neos.Neos.Ui' diff --git a/Resources/Private/Translations/en/Main.xlf b/Resources/Private/Translations/en/Main.xlf index 29f22bbcf3..e2ed58b391 100644 --- a/Resources/Private/Translations/en/Main.xlf +++ b/Resources/Private/Translations/en/Main.xlf @@ -326,6 +326,17 @@ Discarded {0} changes. + + Successfully published all changes to "{workspace}". + + + Switched base workspace to "{workspace}". + + + Your personal workspace currently contains unpublished changes. + In order to switch to a different target workspace you need to either publish or discard pending changes first. + + Syncronize with the title property From 33140ef45f3d0ba40c4906732d01d3c2f3aadea2 Mon Sep 17 00:00:00 2001 From: pKallert <91674611+pKallert@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:40:41 +0100 Subject: [PATCH 2/2] Fix: Spacing --- Classes/Controller/BackendServiceController.php | 2 +- Classes/Controller/TranslationTrait.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index 4b6b0e6543..90420fa313 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -244,7 +244,7 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa $success = new Success(); $changesCount = count($nodeContextPaths); $success->setMessage( - $this->getLabel('changesPublished', [$changesCount,$targetWorkspaceName], $changesCount) + $this->getLabel('changesPublished', [$changesCount, $targetWorkspaceName], $changesCount) ); $updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName); diff --git a/Classes/Controller/TranslationTrait.php b/Classes/Controller/TranslationTrait.php index a83df525c7..b4f022e220 100644 --- a/Classes/Controller/TranslationTrait.php +++ b/Classes/Controller/TranslationTrait.php @@ -28,7 +28,7 @@ trait TranslationTrait /** * @param array $arguments */ - public function getLabel(string $id, array $arguments = [], ?int $quantity=null): string + public function getLabel(string $id, array $arguments = [], ?int $quantity = null): string { return $this->translator->translateById( $id,