From 6d76b94644dba4d66bf94c5422bb054467b58298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Apr 2025 18:23:58 +0200 Subject: [PATCH] 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. --- .../Export/Formatter/SpreadSheetFormatter.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 330231f8e..45d85d8aa 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -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)