Translation Not Working on Breadcrumbs Added by XML – Fix

localisation

I'm building a custom page.

I add breadcrumbs like this (and it works well).

<brand_brand_index translate="label">
        <reference name="breadcrumbs">
            <action method="addCrumb">
                <crumbName>Home</crumbName>
                <crumbInfo>
                    <label>Home</label>
                    <title>Home</title>
                    <link>/</link>
                </crumbInfo>
            </action>
            <action method="addCrumb">
                <crumbName>All Brands</crumbName>
                <crumbInfo>
                    <label>All Brands</label>
                    <title>All Brands</title>
                </crumbInfo>
            </action>
        </reference>
        [[...]]
    </brand_brand_index>

The problem is label not translated in front-end. It shows Home / All Brands instead of translated version.

The things I made sure:

  1. Added translate="label" to handler
  2. Cache cleared (acctually I turned off caching)
  3. Translation syntax is correct (I put in Mage_Core.csv)
  4. Label is translated properly by php code (eg: $helper->__('All Brands');

Help me to figure it out, please.

Thank you.

Best Answer

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.

Related Topic