Ability to add Translation for CMS page and CMS block. Added translation as a custom variable. #164 #506

wants to merge 4 commits into


None yet
3 participants

miguelbalparda commented Feb 16, 2014

Translate CMS Pages in Magento.

Use: In any CMS Page or Block use {{translate text="Text here"}} and the text will be translatable with the Inline translator.

Also available as custom variable:

@miguelbalparda miguelbalparda commented on the diff Feb 16, 2014

@@ -218,9 +218,12 @@ public function deleteAction()
public function wysiwygPluginAction()
- $customVariables = $this->_objectManager->create('Magento\Core\Model\Variable')->getVariablesOptionArray(true);
+ $variablesModel = $this->_objectManager->create('Magento\Core\Model\Variable');

miguelbalparda Feb 16, 2014


Removed double call to $this->_objectManager->create('Magento\Core\Model\Variable') and changed name of var to variablesModel instead of variables.

tanya-soroka self-assigned this Feb 18, 2014

Hello @miguelbalparda, thank you for submit this suggestion!
We have already discussed this improvement and added to our product backlog.
We will review your code changes and provide our feedback.


miguelbalparda commented Feb 18, 2014

Thank you @tanya-soroka! I will add 2 more comments tomorrow to clarify my code so its easy to re use.

@miguelbalparda miguelbalparda commented on the diff Feb 18, 2014

@@ -159,6 +159,27 @@ public function validate()
+ * Retrieve translation option
+ *
+ * @param bool $withGroup
+ * @return array
+ */
+ public function getTranslateVariablesOptionArray($withGroup = false)
+ {
+ $optionArray[] = array(

miguelbalparda Feb 18, 2014


$optionArray[] may be be used as $optionArray

@miguelbalparda miguelbalparda commented on the diff Feb 18, 2014

@@ -126,4 +126,17 @@ public function widgetDirective($construction)
return $widget->toHtml();
+ /**
+ * Generate translatable text
+ *
+ * @param array $construction
+ * @return __
+ */
+ public function translateDirective($construction)

miguelbalparda Feb 18, 2014


The actual translateDirective() function is placed here due to a previous extension i made for Magento 1. In the Magento 1 extension it was here because the module class extended Mage_Widget_Model_Template_Filter for not losing the {{widget ...}} directive.

Hello @miguelbalparda. Thank your submission.
We are going to make additional changes in the scope of the i18n implementation, so your request will be added after changes complete. Due to other priorities, it is unlikely that we will be able to include it in the initial Magento 2.0 release, but we will consider it for a follow-on release.

Thank you for your


maksek commented Dec 26, 2014

Hi @miguelbalparda, thank you for you contribution. Can you please review the PR and resubmit it with latest code into develop branch. Thanks you.

@maksek maksek assigned maksek and unassigned tanya-soroka Dec 26, 2014


miguelbalparda commented Dec 26, 2014

Done @maksek, see #875

@magento-team magento-team pushed a commit that referenced this pull request Apr 3, 2016

@kandy kandy Merge pull request #506 from magento-dragons/PR
[Dragons] Bugfixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment