Language Order Customization

In Orbe, the language list within the selector is ordered by default according to how it's being added to Shopify. However, it's possible to customize this order using CSS, allowing you to prioritize certain languages by placing them at the top of the list.

For example, in this language selector, you can see that Dansk and Italian are at the top when you open the selector:

Here's a step-by-step guide on how to achieve this through Custom CSS:

Step 1: Modify the display of the list

To start, we need to change the display setting of the language list to a grid layout. This allows us to reorder the languages:

.md-form__select__language__list {
    display: grid;
}

.md-form__select__language__list[hidden] {
    display: none;
}

Step 2: Set Default Order

Next, set a default order for all languages in the list. This ensures that any language not explicitly reordered will follow this default setting:

.md-form__select__language__list li {
    order: 2;
}

Step 3: Reorder Specific Languages

Now, you can select specific languages and assign them a different order. In this example, we're moving English (EN) and Spanish (ES) to the top of the list:

.md-form__select__language__list li[data-locale="it"], 
.md-form__select__language__list li[data-locale="da"] {
    order: 1;
}

Adding these CSS classes allows you to customize the order of languages within the Orbe selector easily. Just replace "it" and "da" with the language codes of your preferred languages to tailor the list to your needs. This refers to the ISO two-letter code (alpha-2) of the language.

Complete Code Example

Here's the complete CSS snippet for repositioning Italian and Dansk at the top of the list:

.md-form__select__language__list {
    display: grid;
}

.md-form__select__language__list[hidden] {
    display: none;
}

.md-form__select__language__list li {
    order: 2;
}

.md-form__select__language__list li[data-locale="it"], 
.md-form__select__language__list li[data-locale="da"] {
    order: 1;
}

With this customization, you can enhance the user experience by highlighting the most relevant languages for your customers.

Last updated