Child pages
  • Module translation

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The module's text strings are written in English, but you might want French, Spanish or Polish shop owners to use your module too. You therefore have to translate those strings into those languages, both the front-office and the back-offices strings. Ideally, you should translate your module in all the languages that are installed on your shop. This could be a tedious task, but Smarty and PrestaShop's own translation tool make it far easier.

In short, PrestaShop implements its own translation mechanism, through the use of the l (lowercase L) method, used to encapsulate the strings to be translated.. This method is applied in a different way depending of the file type.

Strings in PHP files will need to be displayed through the l($this->l('My string.') method call, which comes from the Module abstract class, and thus is available in all modules.

Code Block
titlemymodule.php (partial)
$this->displayName = $this->l('My module');
$this->description = $this->l('Description of my module.');



There are specific context where $this->l() will not work: when your module has a front-end controller, that controller's strings must be put in a $this->module->l('My string', 'filename') method call.

For instance, in the /bankwire/controllers/front/validation.php file:

die($this->module->l('This payment method is not available.', 'validation'));

This is a very specific case, and you should not often have to use it. Keep to $this->l(), unless your code breaks because of it when in a FrontController context.


Strings in TPL files will need to be turned into dynamic content using the {l s='My string' mod='modulename'} function call, which Smarty will replace by the translation for the chosen language. In our sample module, the mymodule.tpl file...