Magento Themes and Magento Extensions

Magento : How add translation ability into cms page or static block ?


As we all know magento have multi-language store. Magento use following syntax in .pthml to make text translate to multi-language which is like this :

    <?php   echo $this->__('text to translate'); ?>


    <?php   echo Mage::helper('ModuleName')->__('text to translate');  ?>

But text written in cms page or static block have not translation ability.
To make cms page or static block text compatible with translation ability we need to do some extra coding work which is like this:

We can use following directive in cms page or static block

{{translate text="text to translate"}}

To make it working in cms page or static block we need to add directive function in magneto code as show in following steps.

1. Go to app/code/core/Mage/Core/Model/Email/Template/ and download Filter.php file

2. open Filter.php and add following function after function mediaDirective(), found at approximate Line : 280

public function translateDirective($construction)
	$params = $this->_getIncludeParameters($construction[2]);
	$text = $params['text'];
        return Mage::helper('page')->__($text);

3. Save file.

4. Next upload Filter.php in new custom location : app/code/local/Mage/Core/Model/Email/Template/

5 Now you can easily use following directive in any cms page or static block.

{{translate text="text to translate"}}

Comments are closed.