Skip to content

Commit 1d3539d

Browse files
committed
fix: properly translate TranslatableInterface column labels in export
1 parent 133c2ad commit 1d3539d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/Column/Type/ColumnType.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,21 @@ public function buildExportHeaderView(ColumnHeaderView $view, ColumnInterface $c
108108
$label = $options['label'] ?? StringUtil::camelToSentence($column->getName());
109109

110110
if ($this->translator) {
111-
$translationDomain = $options['export']['header_translation_domain']
112-
?? $options['header_translation_domain']
113-
?? $view->parent->parent->vars['translation_domain']
114-
?? false;
115-
116-
if ($translationDomain) {
117-
$label = $this->translator->trans(
118-
id: $label,
119-
parameters: $options['header_translation_parameters'],
120-
domain: $translationDomain,
121-
);
111+
if ($label instanceof TranslatableInterface) {
112+
$label = $label->trans($this->translator, $this->translator->getLocale());
113+
} else {
114+
$translationDomain = $options['export']['header_translation_domain']
115+
?? $options['header_translation_domain']
116+
?? $view->parent->parent->vars['translation_domain']
117+
?? false;
118+
119+
if ($translationDomain) {
120+
$label = $this->translator->trans(
121+
id: $label,
122+
parameters: $options['header_translation_parameters'],
123+
domain: $translationDomain,
124+
);
125+
}
122126
}
123127
}
124128

0 commit comments

Comments
 (0)