From 1d3539d27131c86c0982d70fa45a7edf3e899298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wr=C3=B3blewski?= Date: Sat, 3 Feb 2024 15:21:19 +0100 Subject: [PATCH] fix: properly translate TranslatableInterface column labels in export --- src/Column/Type/ColumnType.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Column/Type/ColumnType.php b/src/Column/Type/ColumnType.php index 852a441c..c15ecf7a 100755 --- a/src/Column/Type/ColumnType.php +++ b/src/Column/Type/ColumnType.php @@ -108,17 +108,21 @@ public function buildExportHeaderView(ColumnHeaderView $view, ColumnInterface $c $label = $options['label'] ?? StringUtil::camelToSentence($column->getName()); if ($this->translator) { - $translationDomain = $options['export']['header_translation_domain'] - ?? $options['header_translation_domain'] - ?? $view->parent->parent->vars['translation_domain'] - ?? false; - - if ($translationDomain) { - $label = $this->translator->trans( - id: $label, - parameters: $options['header_translation_parameters'], - domain: $translationDomain, - ); + if ($label instanceof TranslatableInterface) { + $label = $label->trans($this->translator, $this->translator->getLocale()); + } else { + $translationDomain = $options['export']['header_translation_domain'] + ?? $options['header_translation_domain'] + ?? $view->parent->parent->vars['translation_domain'] + ?? false; + + if ($translationDomain) { + $label = $this->translator->trans( + id: $label, + parameters: $options['header_translation_parameters'], + domain: $translationDomain, + ); + } } }