Refactor title translation logic in SpreadSheetFormatter.

Simplified and streamlined the handling of title translation. Added truncation for titles exceeding 30 characters to ensure proper formatting. This enhances code readability and ensures title length consistency.
This commit is contained in:
Julien Fastré 2025-04-25 18:23:58 +02:00
parent ff6ec45575
commit 6d76b94644
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -443,10 +443,16 @@ class SpreadSheetFormatter implements FormatterInterface, ExportManagerAwareInte
$original = $this->export->getTitle();
if ($original instanceof TranslatableInterface) {
return $original->trans($this->translator, $this->translator->getLocale());
$title = $original->trans($this->translator, $this->translator->getLocale());
} else {
$title = $this->translator->trans($original);
}
return $this->translator->trans($original);
if (30 < strlen($title)) {
return substr($title, 0, 30).'…';
}
return $title;
}
protected function initializeCache($key)