Skip to content

Commit

Permalink
fix: properly translate TranslatableInterface column labels in export
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreyu committed Feb 3, 2024
1 parent 133c2ad commit 1d3539d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Column/Type/ColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
}

Expand Down

0 comments on commit 1d3539d

Please sign in to comment.