This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Esun\Translation\Block\Adminhtml\Cms\Block\Edit\Button;
use Esun\Translation\Model\Config;
use Magento\Cms\Block\Adminhtml\Block\Edit\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class Translate extends GenericButton implements ButtonProviderInterface
{
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Cms\Api\BlockRepositoryInterface $blockRepository,
private readonly Config $config
) {
parent::__construct($context, $blockRepository);
}
public function getButtonData(): array
{
$blockId = (int)$this->getBlockId();
if (!$this->config->isEnabled() || $blockId <= 0) {
return [];
}
return [
'label' => __('Translate'),
'class' => 'action-secondary',
'on_click' => sprintf(
"location.href = '%s';",
$this->getUrl(
'esun_translation/translate/index',
['entity_type' => 'cms_block', 'entity_id' => $blockId]
)
),
'sort_order' => 85,
];
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Esun\Translation\Block\Adminhtml\Cms\Page\Edit\Button;
use Esun\Translation\Model\Config;
use Magento\Cms\Block\Adminhtml\Page\Edit\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class Translate extends GenericButton implements ButtonProviderInterface
{
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Cms\Api\PageRepositoryInterface $pageRepository,
private readonly Config $config
) {
parent::__construct($context, $pageRepository);
}
public function getButtonData(): array
{
$pageId = (int)$this->getPageId();
if (!$this->config->isEnabled() || $pageId <= 0) {
return [];
}
return [
'label' => __('Translate'),
'class' => 'action-secondary',
'on_click' => sprintf(
"location.href = '%s';",
$this->getUrl(
'esun_translation/translate/index',
['entity_type' => 'cms_page', 'entity_id' => $pageId]
)
),
'sort_order' => 85,
];
}
}