Get Free Audit

Developer Tips: Translations for Module Custom Scripts

Aug 9, 2012

544 Alex Simonchik

While creating a PrestaShop module, there are some cases when you need to write a separate php script, a new module tab, class, etc. Customers, who have purchased the module, very often complain that translations are not working in these files.

How to organize label translations properly over there? How to make these translations appear in the same group with translations of the module, created in Tools -> Translations?

In such cases it would be preferable to apply composition.

If a module has its own tab in the back-office or custom class, we should override l method of this class:

Andrey_Dubina

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

If we create a script-controller (for example, http://my-store.com/modules/my_module/controller.php), don’t forget to add l function in there:

Important note: If you omit the second parameter in the $ myModule-> l ($ string, ‘filename’) method, translations will not work correctly. It happens because translated strings will be saved only for the main script of ‘MyModule.php’ module. The second parameter specifies for which file translation is created.

modules prestashop belvg

PrestaShop Templates

Take your online store to the next level with BelVG PrestaShop Templates

Visit the store
Andrey Dubina

Partner With Us

Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

1 comment

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *