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,51 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Block\Adminhtml\Cms\Block\Edit\Button;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class Translate extends \Magento\Backend\Block\Widget\Container implements ButtonProviderInterface
{
private function getCurrentStoreFromRequest(): int
{
$store = (int)$this->getRequest()->getParam('store', 0);
if ($store <= 0) {
$store = (int)$this->getRequest()->getParam('store_id', 0);
}
return $store > 0 ? $store : 0;
}
public function getButtonData(): array
{
$blockId = (int)$this->getRequest()->getParam('block_id');
if ($blockId <= 0) {
return [];
}
$config = [
'entityType' => 'cms_block',
'entityId' => $blockId,
'sourceStoreId' => $this->getCurrentStoreFromRequest(),
'storesUrl' => $this->getUrl('localetranslate/translation/stores'),
'fieldsUrl' => $this->getUrl('localetranslate/translation/fields'),
'applyUrl' => $this->getUrl('localetranslate/translation/apply'),
'autoTranslateUrl' => $this->getUrl('localetranslate/translation/autotranslate'),
];
$configJson = (string)json_encode(
$config,
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
);
return [
'label' => __('Translate'),
'class' => 'action-secondary',
'on_click' => sprintf(
"require(['Esun_MultiLocaleTranslation/js/translate-modal'], function (openModal) { openModal(%s); });",
$configJson
),
'sort_order' => 30,
];
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Block\Adminhtml\Cms\Page\Edit\Button;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class Translate extends \Magento\Backend\Block\Widget\Container implements ButtonProviderInterface
{
private function getCurrentStoreFromRequest(): int
{
$store = (int)$this->getRequest()->getParam('store', 0);
if ($store <= 0) {
$store = (int)$this->getRequest()->getParam('store_id', 0);
}
return $store > 0 ? $store : 0;
}
public function getButtonData(): array
{
$pageId = (int)$this->getRequest()->getParam('page_id');
if ($pageId <= 0) {
return [];
}
$config = [
'entityType' => 'cms_page',
'entityId' => $pageId,
'sourceStoreId' => $this->getCurrentStoreFromRequest(),
'storesUrl' => $this->getUrl('localetranslate/translation/stores'),
'fieldsUrl' => $this->getUrl('localetranslate/translation/fields'),
'applyUrl' => $this->getUrl('localetranslate/translation/apply'),
'autoTranslateUrl' => $this->getUrl('localetranslate/translation/autotranslate'),
];
$configJson = (string)json_encode(
$config,
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
);
return [
'label' => __('Translate'),
'class' => 'action-secondary',
'on_click' => sprintf(
"require(['Esun_MultiLocaleTranslation/js/translate-modal'], function (openModal) { openModal(%s); });",
$configJson
),
'sort_order' => 30,
];
}
}