Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
20 changes: 20 additions & 0 deletions app/code/Magento/Core/Model/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Widget/Model/Template/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,17 @@ public function widgetDirective($construction)

return $widget->toHtml();
}

/**
* Generate translatable text
*
* @param array $construction
* @return string
*/
public function translateDirective($construction)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this method use?

{
$params = $this->_getIncludeParameters($construction[2]);
$text = $params['text'];
return __($text);
}
}