Shopify - How to change the position of the language switcher?

In this article, you'll learn the different methods to change the position of the Weglot language switcher depending on your Shopify website.

1. Use the Switcher Editor feature

The switcher editor allows you to move the language switcher in context on your website by dragging and dropping the button on a preview of your website.

To use it, you can follow this article: How to use the Switcher Editor?

⚠️ Note that your website must be live and accessible to be able to use the Switcher Editor

You can create your own language switcher in your main menu, for example, and then link it to the Weglot translations.

To do that, go to Shopify Admin > Online Store > Navigation. Click on the menu where you want to add your language switcher:

Then, click on " Add menu item" and add the languages you’ve already added to your store with Weglot:

In the " Name" field, add the language, and in the "link" add #Weglot-language code. For example, for the English button, add #Weglot-en for a French button, you will have to add #Weglot-fr.

Note that the capital letter on the 'W' is important. Example below:

Click on " Apply changes" and then "Save menu" and it's done.

Note that you can also display it as a drop-down menu.

To do that, click on "Add menu item" then, in the "Name" field, you can add "Languages" for example, then add # as the link and click on "Add":

Then drag and drop the language items underneath " Languages" so they become subitems:

You can find more information about this method in our Developer Documentation

3. The Weglot_here option

You can paste the code below into your Theme.liquid file (or into another liquid file) at the place you want the language switcher to be displayed:

<div id="weglot_here"></div>

4. The switcher option

You can also integrate the switcher manually to any elements present in your Shop by adding the "Switchers" option to your Weglot.initialize code

To do that, go to your Shopify admin > Online Store > Themes > Action > Edit Code > Snippets > weglot_switchers.liquid.
You should see the following code (with your own API key instead of YOUR_API_KEY):
<!--Start Weglot Script--> 
<script src=“//”></script>
<script id=“has-script-tags”>Weglot.initialize({ api_key:“YOUR_API_KEY” });</script>
<!--End Weglot Script-->
Add the following piece of code after “ YOUR_API_KEY” (just delete any of the old code after your API key):
    switchers: [
    button_style: {
        full_name: true,
        with_name: true,
        is_dropdown: true,
        with_flags: true,
        flag_type: "circle"
    location: {
        target: ".header-nav", // You'll probably have to change it (see the step below in order to find the correct CSS selector)
        sibling: null

Important: don’t forget the comma after your API key.

The piece of code that’s important here is the “.header-nav” as this determines the location of your language switcher. This needs to be replaced with the CSS selector of the parent element where you want the language switcher to be placed.

⚠️ To find the CSS selector (the "target"):

  • Right-click on the element you want to place the language switcher into.
  • Go to "Inspect"
  • Use the arrow on the top left of the console.
  • Right-click on the element in the console.
  • Copy > Copy selector
  • Paste the code target field between the double quotes

So, for example, if you want to add it to your menu:

<nav class="menu">

Your target line will be:

target: ".menu",

You can find more information about this method in our Developer Documentation

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us