Child pages
  • Translations in PrestaShop 1.5

Versions Compared

Key

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

...

Translations in PrestaShop 1.5

File paths and descriptions

PrestaShop has several types of translations:

...

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, and present them to the translator.

Front-office translations

The following folders are parsed:

...

Note

If the same string appears in several different controllers, it will appear as many times in the translation tool.

On the other hand, if one string appears in both a controller and its template, it will only appear once for this controller.

Back-office translations

The following folders are parsed:

...

Note

If the same string appears in several different controllers, it will appear as many times in the translation tool.

On the other hand, if one string appears in both a controller and its template, it will only appear once for this controller.

Error messages translations

The following folders are parsed:

...

Note

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

Field names translation

The following folder is parsed:

...

The identification key is built by combining the name of the class from which the string comes, an underscore, and the MD5 hash of the string itself.

Installed module translations

Note

When in production mode, only the currently installed modules can be translated. If you wish translate all modules, whether installed or not, you must put your installation of PrestaShop in "debug" mode.

...

Note

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

PDF files translations

The following folders are parsed:

...

Note

If the same string appears in several different controllers, it will appear as many times in the translation tool.

On the other hand, if one string appears in both a controller and its template, it will only appear once for this controller.

E-mail template translations

There are two types of translation when touching upon e-mail templates: the template itself, and the mail object/title. They are completely different things.

Mail objects

The following folders are parsed:

...

The identification key is built by using the original string directly.

Mail templates

The following folders are parsed:

...

  • If the /mails/en/account.html file exists, then it will be translatable for each language enabled in the back-office.

  • If the /themes/name_of_the_theme/mails/en/account.txt file does not exist, then it will not be available for translation in the back-office.

Sprintf

...

Translating the installer

By default, the installer in handful of languages: French, English, Spanish, Portuguese, etc. But you might want to help users from your country by translating the installer in a language that is not yet featured.

Let's work with Vietnamese, for instance.

Note

The following is based on PrestaShop 1.5.4.0, some parts may not work for earlier versions of PrestaShop.

You must have PrestaShop extracted to some directory, for instance /var/www/prestashop. You should be able to access it the URL http://localhost/prestashop.

Put the necessary file structure in place

Make sure to follow this process:

  • go to your install directory (/var/www/prestashop/install, or /var/www/prestashop/install-dev if you have a development version)
    • in the /langs folder, duplicate the /en folder and rename it to /vn
    • in the /fixtures/apple/langs folder, duplicate the /en folder and rename it to /vn
  • in your /langs/vn/img folder, rename all the files substituting the /en prefix with /vn: for instance en-default-category.jpg becomes vn-default-category.jpg.
    If you use Linux, you could for instance run the following command:

    Code Block
    for i in en*; mv $i `echo $i | sed 's/en/vn/'`
Info

The language code of Vietnamese in PrestaShop is "vn", not ISO 639-1's "vi". PrestaShop sometimes deviates from the standards for various reasons, but now it is too late to change everything.

Therefore, you should first check that you are indeed using the correct language code:

  • The main languages are listed here: http://www.prestashop.com/en/translations. The correct code is in the "ISO CODE" column.
  • If your language is not in the list, you can use any two-letter code from the ISO-639-1 list, as long as it is not already used.

In any case, you should first contact PrestaShop's translation team to make sure you do not work at the same time as another contributor.

Setting the details for the new language

Edit the file /langs/vn/language.xml and put the appropriate values. Instead of:

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<language>
  <name><![CDATA[English (English)]]></name>
  <language_code>en-us</language_code>
  <date_format_lite>m/j/Y</date_format_lite>
  <date_format_full>m/j/Y H:i:s</date_format_full>
  <is_rtl>false</is_rtl>
</language>

...you need to use the corresponding values in the language:

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<language>
  <name><![CDATA[tiếng Việt (Vietnamese)]]></name>
  <language_code>vn-VN</language_code>
  <date_format_lite>d.m.Y</date_format_lite>
  <date_format_full>d.m.Y H:i:s</date_format_full>
  <is_rtl>false</is_rtl>
</language>

Inside the <name></name> tag, the first word is the language name in that language itself, the second word (in parenthesis) is the language name in English.

At this point, the only missing thing is the country flag. Download the free FamFamFam Flag Icons pack, and find the flag for the language's main country (or most representative). Use the .png version of the file.

Here is what the installer looks like now:

Image Added

At this point, you should perform a full installation and check that it completes successfully. If it does not, you probably did something wrong, such as forgetting to rename all the images... Please go back up and check everything!

Starting the installer translation

If the installation succeeded, you can start translating! Here is how:

  • Go to http://localhost/prestashop/install/dev/translate.php, select "vn" in the dropdown, and translate! The "Submit" button is at the bottom of the page. Save your work regularly.
  • Once this is done, open the file names /langs/vn/install.php with a text editor, and complete the few translations that are not present in the interface : search for "menu_welcome", "menu_license", "menu_system", "menu_database", "menu_configure" and "menu_process". They are usually at the beginning of the file. Take care of escaping all the single quotes with backslashes if you use some in the translation: "Terry/'s". Adjust the information block if needed.

Last steps

There are many things we did not translate yet, they are contained in the XML files:

  • /langs/vn/data/*.xml: those are the most important, open them in a code editor and translate the contents (everything that looks like real English sentences, not the tags or attributes names!). Pay attention not to translate anything that is an ID! If unsure what to translate in those files, ask away!
  • /fixtures/apple/langs/vn/*.xml: same principle as above, these are the translations of the demo products.
  • There are images in /langs/vn/img. Some of them contain English text: edit them with your favorite image editor.

 

Tip

Try installing PrestaShop regularly while you translate, so that if the installation fails you will find more easily what change caused it to fail!

Once you have done all this please share your work with the community by contacting [email protected], or just make a pull request!

 

Sprintf

The sprintf() function, which is standard to PHP, must be used in the correct way throughout PrestaShop.

...