Read More
Read More
Menu Close

    Translate phrases in overridden files in PrestaShop

    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.

    ie:

    $this->errors[] = $this->trans(
        'This voucher does not exist.',
        [],
        'Shop.Notifications.Error'
    );

    To overcome this issue, we simply need to create the module instance and use the old translation method:

    ie:

    $objModule = Module::getInstanceByName('wktestmodule');
    $this->errors[] = $objModule->l('This is custom error message.');
    image-74
    Translation phrase available in the module

    That’s all.

    Searching for an experienced
    Prestashop Company ?
    Read More

    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].

    . . .
    Discuss on Helpdesk

    Leave a Comment

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


    Be the first to comment.

    Back to Top