PrestaShop:翻译overrided控制器

问题描述:

我已经创建了一个覆盖AdminProductController.php并创建一个新的bulk_action的模块。PrestaShop:翻译overrided控制器

<?php 
class AdminProductsController extends AdminProductsControllerCore 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     $this->bulk_actions['setprice'] = array(
      'text' => $this->l('Set a price for selected'), 
      'icon' => 'icon-price', 
     ); 
    } 
} 

现在我需要翻译动作文本并将该翻译与模块分发。 问题是我看不到模块翻译中的原文,而是在后台翻译中可见。

那么,有没有办法将这个字符串添加到模块翻译而不是后台翻译? 。

的主要问题描述我在这里找到:How to get translation from other module in PrestaShop?

这是因为翻译控制器使用正则表达式在模块文件夹内扫描$ this-> l((。*))并将可翻译字符串添加到文件中 因此,我们应该在模块中做类似下面的操作:

class MyModule extends Module 
{ 

    public static $l = null; 
    public function __construct() 
    { 
     parent::__construct(); 
     $this::$l = $this->l('Set a price for selected'); 
    } 
} 

比控制器,我们可以做什么建议由@TheDrot:

class AdminProductsController extends AdminProductsControllerCore 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     $module = Module::getInstanceByName('modulename'); 
     $this->bulk_actions['setprice'] = array(
      'text' => $module->l('Set a price for selected'), 
      'icon' => 'icon-price', 
     ); 
    } 
} 

您可以通过创建你想要的翻译是在一个模块的情况下做到这一点

class AdminProductsController extends AdminProductsControllerCore 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     $module = Module::getInstanceByName('modulename'); 
     $this->bulk_actions['setprice'] = array(
      'text' => $module->l('Set a price for selected'), 
      'icon' => 'icon-price', 
     ); 
    } 
} 
+0

到目前为止它没有帮助。该短语从后台选项卡中消失,但未出现在模块选项卡中 – 1099511627776

尝试在地方的这 - $> 1使用下面的代码(“设置一个价格选择了”)

Translate :: getModuleTranslation(YOUR_MODULE_NAME,'为所选的设置价格',FILE_NAME);