2014-07-02 71 views
2

我有prestashop的自定義字段模塊。 ,我想在圖片上Prestashop:如何將翻譯選項添加到模塊字段?

enter image description here

我們怎樣才能做到這一點添加語言翻譯領域,如?

這裏是代碼

<?php 
if (!defined('_PS_VERSION_')) 
    exit; 
class customfield extends Module 
{ 
    private $_hooks = array(  
     'displayBackOfficeHeader', 
     'extrainformation', 
     'actionPaymentConfirmation', 
     'displayHeader' 
     );   
    public function __construct() 
    { 
     $this->name = 'customfield'; 
     $this->tab = 'front_office_features'; 
     $this->version = '1.0'; 
     $this->author = 'PrestashopStore.net'; 
     $this->need_instance = 0; 

     parent::__construct(); 

     $this->displayName = $this->l('Custom fields'); 
     $this->description = $this->l('Allow customer to add custom comment to their order'); 
     $this->confirmUninstall = $this->l('Are you sure you want to uninstall module?'); 
    }  
    public function install() 
    { 
     $langs = Language::getLanguages(); 
     $id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); 

     $parent_id = Tab::getIdFromClassName("AdminTools"); 

     $tab = new Tab(); 
     $tab->class_name = "AdminCustomfield"; 
     $tab->module = $this->name; 
     $tab->id_parent = $parent_id; 
     foreach($langs as $l){ 
      $tab->name[$l['id_lang']] = $this->l('Custom field'); 
     } 

     $tab->save(); 
     if (!parent::install() || !$this->initDb()) 
      return false; 
     foreach ($this->_hooks as $hook) { 
      if(!$this->registerHook($hook)) return false; 
     } 
     return true; 
    } 
    public function initDb(){ 
     return true; 
    } 

    public function uninstall() 
    { 
     $tab_id = Tab::getIdFromClassName("AdminCustomfield"); 
     if($tab_id){ 
      $tab = new Tab($tab_id); 
      $tab->delete(); 
     } 
     if (!parent::uninstall()) return false; 
     return true; 
    } 
    public function hookDisplayHeader($params) 
    { 
     $this->context->controller->addJS($this->_path.'ajax.js'); 
    } 
    public function getContent() 
    { 
     if(Tools::isSubmit('save_customfield')){ 
      $label = addslashes(Tools::getValue('add_label')); 
      $content = addslashes(Tools::getValue('add_content')); 
      $label2 = Tools::getValue('add_label2'); 
      $sql="select *from "._DB_PREFIX_."custom_field"; 
      $resul =Db::getInstance()->executeS($sql); 
      if(!$resul){ 
       $sql="insert into "._DB_PREFIX_."custom_field(id,label,conten,label2) values('','$label','$content','$label2')"; 
       $resul=Db::getInstance()->execute($sql); 
      } 
      else{ 
       $sql="update "._DB_PREFIX_."custom_field set label='$label',conten ='$content',label2='$label2'"; 
       $resul =Db::getInstance()->execute($sql); 
      } 
     } 
     $sql="select *from "._DB_PREFIX_."custom_field"; 
     $custom =Db::getInstance()->getRow($sql);    
     $this->context->smarty->assign('custom',$custom); 
     $this->context->smarty->assign('content',$content); 
     return $this->display(__FILE__,'customfield.tpl'); 
    } 
    public function hookDisplayBackOfficeHeader() 
    { 
     Tools::addCSS((__PS_BASE_URI__).'modules/'.$this->name.'/css/customfield.css', 'all');  
    } 
    public function hookExtrainformation(){ 
     $sql="select *from "._DB_PREFIX_."custom_field"; 
     $id_customer = $this->context->customer->id; 
     $id_cart = $this->context->cart->id; 
     $customfield =Db::getInstance()->getRow($sql); 
     $sql ="select content from "._DB_PREFIX_."custom_content where id_cart =$id_cart"; 
     $content=Db::getInstance()->getRow($sql); 
     $this->context->smarty->assign('content',$content); 
     $this->context->smarty->assign('customfield',$customfield); 
     return $this->display(__FILE__,'extrainformation.tpl'); 
    } 
} 

,你可以在這裏找到也http://www.a2b4.net/customfield.txt代碼的所有模塊 http://www.a2b4.net/customfield.rar

回答

0

出現的是你已經在你的前廳本地化下啓用了語言的標誌>本地化。翻譯工具位於後臺>本地化>翻譯。當你點擊國旗時,它會帶你到所有翻譯頁面。從那裏您可以根據您點擊的標誌/語言手動更改翻譯。

+0

該翻譯僅給出了模塊的變換而不是字段。 – lospicos

相關問題