【问题标题】:Translate Shipping Method Title in Magento在 Magento 中翻译运输方式标题
【发布时间】:2013-01-15 23:15:59
【问题描述】:

我按照以下两个教程创建了一个自定义运输模块

http://techportal.inviqa.com/2011/06/09/creating-a-custom-magento-shipping-method/

http://www.magentocommerce.com/wiki/5_-_modules_and_development/shipping/create-shipping-method-module

我现在需要翻译运输方式标题,但是,我收到以下错误

Invalid method VMR_Shipping_Model_Carrier_Customrate::__(Array
    (
        [0] => Flat Rate: 3-10 Days
    )
)

使用这行代码

$optionTitle = $this->__('Flat Rate: 3-10 Days');

非常感谢任何想法或意见!

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    这是因为__()函数定义在核心块、核心控制器和核心助手的抽象类中,而不是核心模型中。您可以通过设置一个扩展 Mage_Core_Helper_Abstract 的助手并运行该函数来轻松翻译您想要的任何内容。

    echo Mage::helper('vrm_shipping')->__('Flat Rate: 3-10 Days')

    ...或者如果您觉得懒惰,请让抽象助手为您翻译

    echo Mage::helper('core')->__('Flat Rate: 3-10 Days')

    ...但是,我不确定您在做什么的细节,但通常最好在块或模板本身内进行翻译。为什么不调用模板中的__() 函数来输出运输方式呢?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 2016-06-23
      • 2014-12-07
      相关资源
      最近更新 更多