2016-07-05 56 views
0

我使用Magento,我需要幫助在前端使用屬性標籤的翻譯! 我用這對我marketplace.phtml加載屬性標籤Magento如何使用屬性標籤上的翻譯?

<?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的使用管理值,而不是法國的值或英語值。

在此先感謝!

此致,

約翰

回答

0

使用$this->__是核心Magento的幫手其中還包含轉換功能,現在假設你的模塊擴展了核心Magento的助手,這將工作。現在您可以使用主題translate.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管理店視圖轉換>管理屬性選擇屬性和管理每個店鋪視圖屬性,但是,我我不完全確定上下文。雖然我提供的應該可以工作,但有了上下文會提供更好的解決方案。

+0

非常感謝你^^ –