Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix translation for buttons #645

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}