Translation doesn't work on breadcrumbs added by xml
To translate a crumb without using a helper, you can use the translate
attribute for your action
node by using crumbInfo.label
and crumbInfo.title
.
Exemple:
<reference name="breadcrumbs">
<action method="addCrumb" translate="crumbInfo.label crumbInfo.title">
<crumbName>home</crumbName>
<crumbInfo>
<label>Home</label>
<title>Home</title>
<link>/</link>
</crumbInfo>
</action>
<action method="addCrumb" translate="crumbInfo.label crumbInfo.title">
<crumbName>brands</crumbName>
<crumbInfo>
<label>All Brands</label>
<title>All Brands</title>
</crumbInfo>
</action>
</reference>
It's the better way to translate breadcrumbs, use helpers only if you have the set a custom title depend on URL params or something else.
Note that you can also generate links for breadcrumbs using helper class.
Using helper class, above XML block may look like:
<brand_brand_index translate="label">
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<params helper="module/getHomeUrl" />
</action>
<action method="addCrumb">
<crumbName>All Brands</crumbName>
<params helper="module/getBrandUrl" />
</action>
</reference>
[[...]]
</brand_brand_index>
And add the getHomeUrl()
& getBrandUrl()
methods in your module's Helper/Data.php as:
class Namespace_Module_Helper_Data extends Mage_Core_Helper_Abstract
{
//...
public function getHomeUrl()
{
return array(
'label' => Mage::helper('module')->__('Home'),
'title' => Mage::helper('module')->__('Home'),
'link' => Mage::getUrl(),
);
}
public function getBrandUrl()
{
return array(
'label' => Mage::helper('module')->__('All Brands'),
'title' => Mage::helper('module')->__('All Brands')
);
}
}