Magento Certified Developer GuideCategory: 1. BasicsIn what way does the developer mode influence how Magento handles translations
Manish Prakash Staff asked 1 year ago

When developer mode is enabled, global translations are turned off in case of duplicate translation.
Which means that translation of string only happen inside a module, if that string is defined in that module’s translation file. (but again only when duplicate translation for same string is found)

e.g if we did $this->__('XYZ') in Mage_Checkout module, and the translation is present in Mage_Catalog and Mage_Contact module, this won’t translate.
Basically it can be said the ambiguous translation are removed.

We can see below how magento implement it in _addData() function

$scope variable passed below
1. For module translation file its the module name: Excellence_A
2. For theme translation file its false
3. For inline translation is it store id

protected function _addData($data, $scope, $forceReload=false)
    {
        foreach ($data as $key => $value) {
            if ($key === $value) {
                continue;
            }
            $key    = $this->_prepareDataString($key);
            $value  = $this->_prepareDataString($value);
            if ($scope && isset($this->_dataScope[$key]) && !$forceReload ) {
                /**
                 * Checking previos value
                 */
                $scopeKey = $this->_dataScope[$key] . self::SCOPE_SEPARATOR . $key;
                if (!isset($this->_data[$scopeKey])) {
                    if (isset($this->_data[$key])) {
                        $this->_data[$scopeKey] = $this->_data[$key];
                        /**
                         * Not allow use translation not related to module
                         */
                        if (Mage::getIsDeveloperMode()) {
                            unset($this->_data[$key]);
                        }
                    }
                }
                $scopeKey = $scope . self::SCOPE_SEPARATOR . $key;
                $this->_data[$scopeKey] = $value;
            }
            else {
                $this->_data[$key]     = $value;
                $this->_dataScope[$key]= $scope;
            }
        }
        return $this;
    }