Child pages
  • Translations in PrestaShop 1.5

Versions Compared

Key

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

...

For each type of translation, PrestaShop's internal translation tool parses a specific set of folders in order to retrieve all the translatable strings it contains, in order to and present them to the translator.

...

  • Controllers and classes:

    Code Block
    $this->l('Add new root category')
  • PHP files at the root of the /admin/ folder:

    Code Block
    translate('Customer name:')
  • Back-office templates:

    Code Block
    {l s='Add tag'}

...

Warning

This method must not be used within modules, because then the string translations would be saved in the /translations/iso_code/errors.php file instead of the /modules/name_of_the_module/translations/iso_code.php file.

...

Note

If one string appears in several different files, it will only appear once in the translation tool.

Field names translation

...

The string are those returned by the getValidationRules() method from ObjectModule for each class.

All the field names translations are stored in the following file, with iso_code being the ISO 3166-1 code (http://www.iso.org/iso/country_codes.htm) for the language of the translated strings (de, fr, en, it, es, etc.):

...

Warning

The Tools::displayError() method must not be used within modules, because then the string strings' translations would be saved in the /translations/iso_code/errors.php file instead of the modules/name_of_the_module/translations/iso_code.php file.

Since PrestaShop 1.5, you can translate modules depending on the theme. Therefore, the list of translation files is as such:

  • /modules/nomname_of_the_module/translations/iso_code.php: for the default theme.
  • /themes/nomname_of_the_theme/modules/nomname_of_the_module/translations/iso_code.php: for any other theme.

...

The identification key is built by combining the name of the module from which the original string comes (i.e. "blockcms"), following by the name of the theme (i.e. "prestashop"), followed by the name of the file (i.e. "blockmobilecms"), followed by an underscore, and finally the MD5 hash of the string itself.

...

  • /classes/PDF.php
  • /override/classes/PDF.php

  • /classes/pdf/ (new in 1.5)

  • /override/classes/pdf/ (new in 1.5)

  • /pdf/ (new in 1.5)

  • /themes/nomname_duof_the_theme/pdf/ (new in 1.5)

The translatable strings use the following syntax:

  • For classes files, ClassName::l():

    Code Block
    HTMLTemplateInvoice::l('Invoice ')
    
    ...or...
    
    HTMLTemplateDeliverySlip::l('Delivery')
  • For templates:

    Code Block
    {l s='Delivery Address'}

Three Two options can be added to these syntaxes:

...

The second parameter is mandatory. If it is absent, the mail will be sent with an object in the shop's default language.

All the error messages mail translations are stored in the following filefiles, with iso_code being the ISO 3166-1 code (http://www.iso.org/iso/country_codes.htm) for the language of the translated strings (de, fr, en, it, es, etc.):

...

  • /mails/iso_code/: for the default e-mail templates.

  • /themes/name_of_the_theme/mails/iso_code/: for each theme's e-mail templates.

The translate translated e-mail templates are those available in English. For instance:

...