Question

We are having problems with translations on our store for our multi lingual sites.

They used to work ok but when we add modules it seems that the translations are now lost.

As an example "Add to Cart" on the product page used to translate on our French site to "Ajouter au panier" as that was called from the /app/locale/fr_FR/Mage_Catalog.csv file.

When we add a third party module called AW_Productpdates.xml the language on the French store returns to "Add to Cart" and the scope for the translation looks like it changes and is looking for "Add to Cart" in the language file for "AW_Productupdates". As "Add to Cart" has not been translated it will just use the English version.

Is this normal or should it still try and look for "Add to Cart" translation still within the app/locale/fr_FR/ folder?

If it helps, I am still doing some overrides in my /app/frontend/theme/default/locale/fr_FR/translate.csv file but I don't want to replicate the translations if they are already within the /app/locale/fr_FR/ folder.

Was it helpful?

Solution

The problem is that as soon as a module rewrites a block, the translation scope changes. This is also why you often see translations like $this->helper('catalog')->__('Add to Cart') instead of $this->__('Add to Cart') in core templates.

A good practice that sadly few people know of, is to set the scope explicitly in rewritten blocks like this:

class My_Module_Block_Product_View extends Mage_Catalog_Product_View
{

    public function getModuleName()
    {
        return 'Mage_Catalog';
    }

}

Obviously this has not been done in the AW_Productupdates extension.

Now you have several options:

  1. Set the module scope explicitly via layout XML

    <reference name="product.info">
        <action method="setModuleName"><module>Mage_Catalog</module></action>
    </reference>
    
  2. Change the template(s) where "Add to Cart" is translated wrong to explicitly use the catalog helper

  3. Add the translation to translate.csv using the new scope:

    "AW_Productupdates::Add to Cart","Ajouter au panier"
    
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top