Language selector position

Hi, im trying to add a language selector to the header menu for desktop but its position is all messed up. Could anyone help me to place it nicely in alignment with all the menu items and next to the cart and login icons? Thx.

Here’s the code that i used to add it there in header.menu.drop.liquid file

{% form ‘localization’ %}

   <!-- Language selector -->

<select name="locale_code" onchange="this.form.submit()">

  {% for language in localization.available_languages %}

    <option value="{{ language.iso_code }}"

      {% if language.iso_code == localization.language.iso_code %}selected{% endif %}>

      {{ language.endonym_name }}

    </option>

  {% endfor %}

</select>

{% endform %}

Preview link: https://xe5fmdgxc02n2lor-77830390093.shopifypreview.com

Dear @JustinasR

I have checked your website. It seems that you added style snippets to bring the language selector to the desired position on the desktop screen. However, on mobile and tablet devices, you should make the following adjustments to make it look better:

1. Regarding structure: You should not place a div tag inside a ul tag.


2. Regarding styles for mobile: Please remove the display: block; line in .shopify-localization-form on mobile so that its size does not exceed the popup.

Let me know if you need further assistance.

Regards,
Eric

Added it inside the site-actions class. But its still messed up.

{% for language in localization.available_languages %}

<option value=“{{ language.iso_code }}”

{% if language.iso_code == localization.language.iso_code %}selected{% endif %}>

{{ language.endonym_name }}

{% endfor %}

Not sure what exactly these changes will accomplish? Also where do i then place the codes to prevent them being inside ul tag?

Currently desktop version placed in sections → header.liquid and mobile snippets → header.menu.drop.liquid

I managed the desktop to look OK now, but its expanding the whole header column now. Any idea how to improve that?

How it looks now:

vs How it should be:

@shopplaza_team did you have a chance to look at this?

Dear @JustinasR

Could you please share your website again? I can’t access the previous preview link you shared.
https://xe5fmdgxc02n2lor-77830390093.shopifypreview.com

Regards,
Eric from Shopplaza

Here is the preview link: https://csp5254vc8054zb0-77830390093.shopifypreview.com

I managed to solve the header expansion problem. Now i just need to reduce the square box length.

To go from this

To this:

Any ideas pls?

Dear @JustinasR
I checked the reason the select width is stretched, and it is because one of the options has a significantly higher character count compared to the others. If we reduce the width, would you accept the text being hidden?

Regards,
Eric from Shopplaza

Dear @JustinasR

A simpler way is to shorten the characters in the ‘português (Portugal)’ option to ‘Portugal’; that way, the issue will be resolved.

Regards,
Eric from Shopplaza

The default box, collapsed should be shorter. Pls have a look at the form in the footer bottom right. Only once you expand it, then it should be longer.

Dear @JustinasR

The reason for the difference is that the structures of the two positions are different. In the menu, a select element is being used. However, at the bottom position, a button, ul tag, and input are used to create the selector.


To make your button look more similar, you can add the following code to your theme:

...
select[name="locale_code"] {
    max-width: 88px !important;
}
...

Regards,
Eric from Shopplaza

That worked thanks!

Last thing, may I ask also why at the bottom there is a small arrow and not at the top too?

Dear @JustinasR
As I explained in the previous message, the reason is that you are using a select element instead of the default ‘Language’ block structure.

To use the correct block as default, you need to identify the block in the theme editor.

Only then can you use that block in your desired position. Please note that some blocks are only allowed to be used in certain sections.

Regards,
Eric from Shopplaza

That is not what I asked.

The form style on the footer is the correct one and the one that I’d like to use at the top.

The only thing that is missing right now is the small down-pointing arrow that exists on the footer form, but not on the header form. How do i add the same?

This is the arrow i mean

Hi JustinasR,

Thanks for the clarification and for sharing the screenshot.

To ensure the header language selector matches the footer style (including the arrow indicator), we may need to review how the selector is implemented in your theme’s header section. If possible, could you please provide your store URL or collaborator access so we can take a closer look at the theme structure?

Looking forward to your response.

Dear @JustinasR

Let me explain in more detail. The reason the selector you customized above the menu does not look like the default one is because of the structure you used. As you initially described, you used the following code:

 <!-- Language selector -->

<select name="locale_code" onchange="this.form.submit()">

  {% for language in localization.available_languages %}

    <option value="{{ language.iso_code }}"

      {% if language.iso_code == localization.language.iso_code %}selected{% endif %}>

      {{ language.endonym_name }}

    </option>

  {% endfor %}

</select>

It will be displayed on the frontend as follows:

<select name="locale_code" onchange="this.form.submit()">
      
        <option value="en" selected="">
          English
        </option>
      
        <option value="lt">
          lietuvių
        </option>
      
        <option value="de">
          Deutsch
        </option>
      
        <option value="es">
          Español
        </option>
      
        <option value="fr">
          français
        </option>
      
        <option value="it">
          Italiano
        </option>
      
        <option value="pt-PT">
          português (Portugal)
        </option>
      
    </select>

When you compare it with the code of the default selector, you will see the difference.

Next is the solution: the safest solution is to use the block containing the language selector and add it to your desired position. That way, you will have the exact same structure. In case you still have difficulties, please share collaborator access with me. I will be able to help you fix it.

Regards,
Eric from Shopplaza

Hi, @JustinasR
You can search the html code below, then add the html element and related js code to you custom code.


Hope this helps! If you will unable to implement the same then I’m happy to do this for you, let me know.