Categories

Featured templates

PrestaShop 1.6.x. How to display flags in the language switcher

Guillaume Dumas January 29, 2016
Rating: 5.0/5. From 4 votes.
Please wait...

This tutorial will show you how to display flags in the language switcher in the PrestaShop 1.6.x. themes.

PrestaShop 1.6.x. How to display flags in the language switcher

By default the language switcher displays only the names of the installed languages:

PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-1

In order to add a flag in front of each language option in the language switcher, you need to do the following steps:

  1. Go to administration panel -> Localization -> Languages and make sure all your languages have flags. If some of them don’t, you need to upload icons for them. To do it you need to perform the following steps:

    1. Go to http://www.famfamfam.com/lab/icons/flags and download the icons:

      PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-2

    2. Open the zip file you just downloaded and extract the icons you need to your local system.

    3. Go to administration panel – Localization – Languages, click the Edit button for the language in question.

    4. Upload the country flag from your computer:

      PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-3

    5. Save the changes.

  2. Open up the themes/themeXXXX/modules/blocklanguages/blocklanguages.tpl file using your favorite code editor:

    PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-4

  3. Insert the following code before {$language.name|regex_replace:"/\s\(.*\)$/":""} twice on lines 7 and 22 (approximately):

    <img alt="{$language.iso_code}" height="11" span="" src="{$img_lang_dir}{$language.id_lang}.jpg" width="16" style="margin-right: 2px;"/>
    

    so that it will look like this:

    <span><img alt="{$language.iso_code}" height="11" span="" src="{$img_lang_dir}{$language.id_lang}.jpg" width="16" style="margin-right: 2px;"/>{$language.name|regex_replace:"/\s\(.*\)$/":""}</span>
    

    PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-5

  4. Save the changes in the blocklanguages.tpl and re-upload it to the server.

  5. Refresh the main page of your store and now you see a flag in front of each language option in the language switcher:

    PrestaShop_1.6.x._How_to_display_flags_in_the_language_switcher-6

Feel free to check the detailed video tutorial below:

PrestaShop 1.6.x. How to display flags in the language switcher

Premium Prestashop Themes
This entry was posted in PrestaShop Tutorials and tagged flag, language, Prestashop, switcher. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket