From d827e6ce1cfe7f5d7cf3192608aa1440993183f6 Mon Sep 17 00:00:00 2001 From: mhofmann Date: Fri, 28 Jul 2023 11:03:00 +0200 Subject: [PATCH] [BUGFIX] remove whitespaces from glossary terms --- Classes/Client.php | 12 +++++++++++- .../TCA/tx_wvdeepltranslate_glossaryentry.php | 15 ++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Classes/Client.php b/Classes/Client.php index 91746cbf..304f5f3b 100644 --- a/Classes/Client.php +++ b/Classes/Client.php @@ -134,7 +134,17 @@ public function createGlossary( ): GlossaryInfo { $prepareEntriesForGlossary = []; foreach ($entries as $entry) { - $prepareEntriesForGlossary[$entry['source']] = $entry['target']; + /* + * as the version without trimming in TCA is already published, + * we trim a second time here + * to avoid errors in DeepL client + */ + $source = trim($entry['source']); + $target = trim($entry['target']); + if (empty($source) || empty($target)) { + continue; + } + $prepareEntriesForGlossary[$source] = $target; } try { return $this->translator->createGlossary( diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php index 75be7a5a..29e4305f 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php @@ -84,11 +84,16 @@ 'term' => [ 'label' => 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:entry.source', 'l10n_mode' => '', - 'config' => [ - 'type' => 'input', - // @deprecated with v12. Adjusted for v12+ in `Overrides/tx_wvdeepltranslate_glossaryentry.php' - 'eval' => 'required', - ], + 'config' => (new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 + ? [ + 'type' => 'input', + 'required' => true, + 'eval' => 'trim', + ] + : [ + 'type' => 'input', + 'eval' => 'trim,reqiured', + ], ], ], ];