Developer Tips: Translations for Module Custom Scripts

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:

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.



1 comment

Post a new comment

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