miguelbalparda / MB_Translate

Translate CMS Pages in Magento
18 stars 12 forks source link

Pass a module name to the translate directive #2

Closed tzyganu closed 10 years ago

tzyganu commented 10 years ago

In the way is built now all the texts are translated using the page module.
You should be able to pass a module name to the translate directive:

{{translate text="some text here" module="catalog"}}

This can be achieved by doing this:

public function translateDirective($construction)
{
    $params = $this->_getIncludeParameters($construction[2]);
    $text = $params['text'];
    $module = (!empty($params['module'])) ? $params['module'] : 'page';
    return Mage::helper($module)->__($text);
}
miguelbalparda commented 10 years ago

@tzyganu please submit a pull request for this feature. Also it should be optional and have a default value if the $module var is empty.

miguelbalparda commented 10 years ago

Just saw this line:

    $module = (!empty($params['module'])) ? $params['module'] : 'page';
tzyganu commented 10 years ago

@miguelbalparda See my pull request. I've added other things beside the support for module param. Seamed cleaner that way.

miguelbalparda commented 10 years ago

Nice!