马恩托 如何在属性标签上使用翻译


Magento How to use translation on attribute label?

我使用Magento,我需要帮助在前端使用属性标签的翻译!我在我的 marketplace.phtml 上使用它来加载属性标签

<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'etat_verres');
$allOptions = $attribute->getSource()->getAllOptions(true, true);
foreach ($allOptions as $instance) { if($instance['label']) {
echo $instance['value'] // to show the value
echo $instance["label"] // to show the label
} }
?>

问题是Magento使用管理员值而不是法语值或英语值。

提前感谢!

真诚的你,

John

使用$this->__是核心Magento助手,它也包含翻译功能,现在假设您的模块扩展了核心Magento助手,这将起作用。现在,您可以使用主题翻译.csv文件来翻译文本。

<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'etat_verres');
$allOptions = $attribute->getSource()->getAllOptions(true, true);
foreach($allOptions as $instance)
{
    if ($instance['label'])
    {
        echo $this->__($instance['value']) // to show the value
        echo $this->__($instance["label"]) // to show the label
    }
}

另请记住,翻译"标签"应该是不必要的,因为您可以在目录>管理属性中选择您的属性并管理每个商店视图的属性中使用Magento管理员商店视图翻译,但是,我不完全确定上下文。 虽然我提供的内容应该有效,但拥有上下文将提供更好的解决方案。