Skip to content

Commit

Permalink
Fix translations for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
zonky2 committed Aug 5, 2024
1 parent a34178e commit 216bcdb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/Contao/View/Contao2BackendView/ButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ private function buildCommand(
->setCommand($command)
->setObjModel($model)
->setAttributes($attributes)
->setLabel($this->getCommandLabel($command))
->setLabel($this->getCommandLabel($command, $definitionName, ['%id%' => $model->getId()]))
->setTitle(
$this->translateButtonDescription(
str_replace(['.description', '.1'], '', $command->getDescription()),
\preg_replace('#(\.description|\.1)$#', '', $command->getDescription()),
$definitionName,
['%id%' => $model->getId()]
)
Expand Down Expand Up @@ -775,12 +775,16 @@ private function calculateHref(CommandInterface $command, ModelInterface $model)
*
* @return string
*/
private function getCommandLabel(CommandInterface $command): string
private function getCommandLabel(CommandInterface $command, string $definitionName, array $parameter = []): string
{
if ('' === $label = $command->getLabel()) {
$label = $command->getName();
}

return $this->translate($label);
return $this->translateButtonLabel(
\preg_replace('#(\.label|\.0)$#', '', $label),
$definitionName,
$parameter
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ assert($translator instanceof TranslatorInterface);
</div>
<?php endif; ?>
<?php $this->block('parent-header'); ?>
<?php if (!empty($this->header)) : ?>
<?php if ($this->header || $this->headerButtons) : ?>
<div class="tl_header hover-div">
<?php if ($this->headerButtons) : ?>
<div class="tl_content_right">
<?= $this->headerButtons ?>
</div>
<?php endif; ?>
<?php if ($this->header) : ?>
<table class="tl_header_table">
<?php foreach ($this->header as $key => $value) : ?>
<tr>
Expand All @@ -50,6 +53,7 @@ assert($translator instanceof TranslatorInterface);
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<?php endif; ?>
<?php $this->endblock(); ?>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/css/generalDriver.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Resources/public/css/generalDriver.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Resources/public/sass/_headerButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
background-image:url("/system/themes/flexible/icons/stop.svg");
background-size: 16px;
}

.tl_header {
&.hover-div {
&::after {
content: " ";
clear: right;
display: block;
}
}
}

0 comments on commit 216bcdb

Please sign in to comment.