Jump to content

Edit History

REGE

REGE


[SOLVED]

I wrote a sample controller class for my module:

<?php
namespace MyModule\Controller;

use PrestaShopBundle\Translation\Translator;

final class CustomModuleController 
{
    /** @var Translator */
    private Translator $translator;

    public function __construct(Translator $translator)
    {
        $this->translator = $translator;
    }
    
    public function foo()
    {
        $this->text = $this->translator->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass');
    }
}

 

I would like to translate it. Everything seems fine, but the text to be translated does not appear in BackOffice->International->Translations. However, the translations from the main module file mymodule.php are all there.

Am I doing something wrong? How to translate texts from the module controller?

REGE

REGE

I wrote a sample controller class for my module:

<?php
namespace MyModule\Controller;

use PrestaShopBundle\Translation\Translator;

final class CustomModuleController 
{
    /** @var Translator */
    private Translator $translator;

    public function __construct(Translator $translator)
    {
        $this->translator = $translator;
    }
    
    public function foo()
    {
        $this->text = $this->translator->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass');
    }
}

 

I would like to translate it. Everything seems fine, but the text to be translated does not appear in BackOffice->International->Translations. However, the translations from the main module file mymodule.php are all there.

Am I doing something wrong? How to translate texts from the module controller?

×
×
  • Create New...