Magento – Inline translate Chrome Bug

ce-1.7.0.2chrome-browserlocalisation

Maybe it's just me, but in Chrome browser inline translate does not work. The red boxes are shown and if I hover the mouse the book icon appears but if I click it nothing happens. I had the same problem on different servers.

Other browser like Firefox and IE are fine.

Is there a bugfix for this?

Best Answer

Yes, the inline translation feature is broken in Google Chrome. Back when the inline translation feature was originally developed, Magento made use of a non-standard translate attribute in DOM elements to flag translatable text.

Since then, Google Chrome has a feature where a default translate property is added to every DOM node available in javascript (over simplification).

This, in turn, interfers with Magento's PrototypeJS xpath code used to implement the translation feature. Specifically, this

if (!$(target).match('*[translate]')) {
    target = target.up('*[translate]');
}

I solution I came up with last year was to add the following bit of javascript to every page when inline translations are active.

if(Object.__defineGetter__)
{
    var hasTranslateAttribute = function(){
        return $(this).hasAttribute("translate");
    };
    document.observe("dom:loaded", function() {
        $$('*').each(function(theElement){
             theElement.__defineGetter__("translate", hasTranslateAttribute);
        });
    });
}
Related Topic