Skip to content

Commit

Permalink
[BUGFIX] remove whitespaces from glossary terms
Browse files Browse the repository at this point in the history
  • Loading branch information
calien666 committed Jul 28, 2023
1 parent 4c2a739 commit d827e6c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 11 additions & 1 deletion Classes/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 10 additions & 5 deletions Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
],
];

0 comments on commit d827e6c

Please sign in to comment.