Magento: how to translate action tag content?

我怕爱的太早我们不能终老 提交于 2019-12-04 14:55:07

The translate attribute should contain a space-delimited list of tag names to translate. For example, if the argument one is passing to Mage_Core_Block_Text::setText() is encapsulated in ` node, you should have the following:

<action method="setText" translate="foo"><foo>Some text!</foo></action>

Unless one is trying to pass in an array structure via layout XML, argument node names do not matter.

Also worth noting is that if one sets the module attribute, that string will be passed to the helper class factory method (Mage::helper() - see timeline below). For instances where incorrect translation is being seen, verify that there are no overriding entries in the core_translate database table, which would only be entered if inline translation has been used.

Call sequence:

  • Mage_Core_Controller_Varien_Action::loadLayout()
    • ::generateLayoutBlocks()
      • Mage_Core_Model_Layout::generateBlocks()
        • ::_generateBlocks()
          • ::_generateAction()
            • ::_translateLayoutNode()

It is _translateLayoutNode() which processes the translate attributes of the <action /> directives:

if (isset($node['module'])) {
    $args[$arg] = Mage::helper((string)$node['module'])->__($args[$arg]);
}
else {
    $args[$arg] = Mage::helper('core')->__($args[$arg]);
}

Check the name of your locale folder (trailing e)

app/design/frontend/default/default/local/en_US/translate.csv
app/design/frontend/default/default/locale/en_US/translate.csv
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!