Back to Top

Translate phrases in overridden files in PrestaShop

Updated 19 January 2023

In this blog, we will learn how to translate phrases in the override files. Sometimes we need to override the core PrestaShop classes and controllers and need to add some of our own phrases. But when we translate the module, these phrases are not available in the translation list because core files use the new translation system.


$this->errors[] = $this->trans(
    'This voucher does not exist.',

To overcome this issue, we need to create a class in our module, and in this class, we create a method and then create an instance of the module and use the old translation method and return it.


class WkTestTranslation
    public static function getOverrideTransMsg()
        $objModule = Module::getInstanceByName('wktestmodule');
        return $objModule->l('This is custom error message.');

To use the above method, we simply call the method in the module overridden file:

Searching for an experienced
Prestashop Company ?
Find out More

Now, this phrase will be available under the module translation section in the back office:

Translation phrases available in the module

That’s all.

If any issue or doubt in the above process, please feel free to let us know in the comment section.

I would be happy to help.

Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected].

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home