Display flags in the language switcher - P1.6, 1.7

Sometime you want to display flags in the language switcher in your Prestashop theme. Our clients also asked me how to show the flags and sometime wanna display the flags from dropdown to inline.

All you need is open this file : /your-website/themes/classic/modules/ ps_languageselector/ps_languageselector.tpl using your favorite code editor ( my tool: text editor :D ) and change it as you wish.

Display flags in the language switcher - Prestashop 1.6, 1.7

Step I - Language Switcher with flags

Take a look into the file. In both Prestashop 1.6 & Prestashop 1.7, you will find something like that:

  <li {if $language.id_lang == $current_language.id_lang} class="current" {/if}>
              <a href="/{url entity='language' id=$language.id_lang}" class="dropdown-item">
                      {$language.name_simple}
             </a>
  </li>

Ok, now we need to add the flag picture. Change it to:

  <li {if $language.id_lang == $current_language.id_lang} class="current" {/if}>
              <a href="/{url entity='language' id=$language.id_lang}" class="dropdown-item">
                   <img src="https://presta.b-cdn.net/img/l/{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                   {$language.name_simple}
              </a>
  </li>

You might want to show the flag on current language. Find this code:

  {$current_language.name_simple}
  

Change it to:

  <img src="https://presta.b-cdn.net/img/l/{$current_language.id_lang}.jpg" alt="{$current_language.iso_code}" width="16" height="11" /> 
  {$current_language.name_simple}

The language pictures are located in /your-website/img/l/ folder. Save the changes and enjoy the first step!

Step II - Display inline

In case you want to show the flags inline, open above file, remove everything and paste this source code into it:

<span id="language-selector-label" class="hidden-md-up">{l s='Language:' d='Shop.Theme.Global'}
{foreach from=$languages item=language}
            <a href="/{url entity='language' id=$language.id_lang}" style="margin-right:3px; margin-top: .9375rem;">
                   <img src="https://presta.b-cdn.net/img/l/{$language.id_lang}.jpg" style="{if $language.id_lang == $current_language.id_lang}border:3px solid rgba(0, 0, 0, 0.71);{else}border:3px solid #fff;{/if}" alt="{$language.iso_code}" width="22" height="17" />
           </a>
{/foreach}

As you can see, this is a basic and very simple Prestashop tutorial. The most important thing is to make sure your clients know where they are seeking.

If you’re ready to dive in and start customizing your Prestashop website, be sure to download Magic Menu to personalize the website menus as you wish.

Personalize Prestashop Menus

Get this Advanced Cart Rules module

New module.

Xleft module

Xleft shows customers how much more they need to spend to get free shipping in real time.

Latest modules update!

ChargeMe v5.4.1 ⊙
Clear the cart & redirect to the checkout page.


Age Restriction - 18+ v2.3.4⊙
Fix the Smarty issues.


Newsletter Popup v3.2.5 ⊙
Enhance the level of security.


Trusty v1.4.7 ⊙
Compatible with both PrestaShop 1.7 & PrestaShop 8.

PrestaSOO team
Everything you need to make a living doing work you love.

Discover

It is a wise investment

PrestaShop modules we created first to solve the problem of our own business - an e-Commerce site. That means they are very useful for serious business. If you value your web property, these modules are a wise investment.
Sarah Reeves, App Developer @ PrestaSOO
Made with in Paris & Hanoi
PrestaSOO © 2024. All rights reserved. // Privacy Policy Terms of Service