diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Variable/WysiwygPlugin.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Variable/WysiwygPlugin.php index 31dd38503634a..54342e907d21e 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Variable/WysiwygPlugin.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Variable/WysiwygPlugin.php @@ -14,14 +14,16 @@ class WysiwygPlugin extends \Magento\Backend\Controller\Adminhtml\System\Variabl */ public function execute() { - $customVariables = $this->_objectManager->create('Magento\Core\Model\Variable')->getVariablesOptionArray(true); + $objectManager = $this->_objectManager->create('Magento\Core\Model\Variable'); + $customVariables = $objectManager->getVariablesOptionArray(true); $storeContactVariabls = $this->_objectManager->create( 'Magento\Email\Model\Source\Variables' )->toOptionArray( true ); + $translateVariables = $objectManager->getTranslateVariablesOptionArray(true); /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ $resultJson = $this->resultJsonFactory->create(); - return $resultJson->setData([$storeContactVariabls, $customVariables]); + return $resultJson->setData([$storeContactVariabls, $customVariables, $translateVariables]); } } diff --git a/app/code/Magento/Core/Model/Variable.php b/app/code/Magento/Core/Model/Variable.php index 725d458de080a..67c491da12df2 100644 --- a/app/code/Magento/Core/Model/Variable.php +++ b/app/code/Magento/Core/Model/Variable.php @@ -136,6 +136,26 @@ public function validate() return __('Validation has failed.'); } + /** + * Retrieve translation option + * @param bool $withGroup + * @return array + */ + public function getTranslateVariablesOptionArray($withGroup = false) + { + $optionArray[] = [ + 'value' => '{{translate text=""}}', + 'label' => "Translate string" + ]; + if ($withGroup && $optionArray) { + $optionArray = [ + 'label' => __('Translation'), + 'value' => $optionArray + ]; + } + return $optionArray; + } + /** * Retrieve variables option array * @todo: extract method as separate class diff --git a/app/code/Magento/Widget/Model/Template/Filter.php b/app/code/Magento/Widget/Model/Template/Filter.php index e5c7aa30374b2..72ef2985bb9c3 100644 --- a/app/code/Magento/Widget/Model/Template/Filter.php +++ b/app/code/Magento/Widget/Model/Template/Filter.php @@ -107,4 +107,17 @@ public function widgetDirective($construction) return $widget->toHtml(); } + + /** + * Generate translatable text + * + * @param array $construction + * @return string + */ + public function translateDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + $text = $params['text']; + return __($text); + } }