Magento:如何翻译动作标签内容? [英] Magento: how to translate action tag content?

查看:78
本文介绍了Magento:如何翻译动作标签内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有默认的page.xml.

I have default page.xml.

我添加了

<block type="core/text" name="for_everyone">
   <action method="setText" translate="text"><text>Some text!</text></action>
</block> 

<block type="core/text_list" name="content" as="content" translate="label">
    <label>Main Content Area</label>
</block>

我得到了这个:

<block type="core/text_list" name="content" as="content" translate="label">
    <label>Main Content Area</label>
    <block type="core/text" name="for_everyone">
        <action method="setText" translate="text"><title>Some text!</title></action>
    </block> 
</block>

然后我为主题添加了两个文件:

Then I added two files for my theme:

app/design/frontend/default/default/locale/en_US/translate.csv

"Some text!","Some text!"

app/design/frontend/default/default/locale/fr_FR/translate.csv

"Some text!","un text!"

但是,每当我使用任何一种语言时,我都会看到某些文本!".同时,为网站选择的语言正确使用.例如,catalog.xml中的字符串可完美翻译:

But every time I run any language I see "Some text!". At the same time selected lang for website is used correct. For example the string from catalog.xml translates perfect:

<block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml">
      <action method="setImgSrc"><src>images/media/col_right_callout.jpg</src></action>
      <action method="setImgAlt" translate="alt" module="catalog"><alt>Keep your eyes open for our special Back to School items and save A LOT!</alt></action>
</block>

我还尝试使用类似这样的smth和其他标签:

I also tried to use smth like that and other tags:

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

有人知道是什么问题吗?

Does anybody know what the problem is?

推荐答案

translate属性应包含以空格分隔的标记名称列表,以进行翻译.例如,如果将传递给Mage_Core_Block_Text::setText()的参数封装在`node中,则应具有以下内容:

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>

除非试图通过布局XML传递数组结构,否则参数节点名称无关紧要.

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

还值得注意的是,如果设置了module属性,则该字符串将被传递到帮助器类工厂方法(Mage::helper()-请参见下面的时间线).对于发现翻译不正确的情况,请确认core_translate数据库表中没有覆盖的条目,只有在使用了内联翻译的情况下才可以输入这些覆盖的条目.

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.

通话顺序:

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

                      _translateLayoutNode()处理<action />指令的转换属性:

                      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]);
                      }
                      

                      这篇关于Magento:如何翻译动作标签内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆