Monday, February 15, 2010

Translations

If you want to translate something in PrestaShop, don't edit any files!

This is the way to do it

  • In the Back Office, go to Tools and Translations
  • Select where the translation is to be made, usually in a Module or the Front Office, and click the flag of the country whose language you want to translate to
  • Click Expand all fieldsets and search for the phrase you want to translate
  • Enter the translation and click Update Translations
Simple as that
What this does is add the translated phrase(s) to a file called xx.php where xx is the ISO-Code of the country (where it is located depends on what you have translated).
It is also (I guess) possible to edit that file directly but I wouldn't recommend it.

OK, that's not too hard, but what if I want to add some text and translate that?

Lets say we want to add the text "This is a test shop, please do not order anything" to all product pages.

  • Go to the themes directory (themes/prestashop by default) and edit the file product.tpl
  • Enter this where you want the text to appear {l s='This is a test shop, please do not order anything'}
  • Then follow the steps above and you will see that the phrase has popped up to be translated in the Back Office
Note that if the phrase is located in a module the xxx.tpl file is located in modules/xxx where xxx is the name of the module, and that you need to add the module name in the code, ie
{l s='This is a text to be shown in a module' mod='xxx'}
If you forget about the mod='xxx', the phrase will show up to be translated in the Back Office, but the translated phrase will never show up in the shop.

If you want to change a text, I'd advise you not to change it in the code but instead use the translation tool and translate from English to English.

1 comment:

  1. The blog posted is very interesting from all aspects and it will surely benefit the readers by all means.
    Prestashop Theme Developer

    ReplyDelete