A user needed to reorder languages in their Craft theme’s header language selector, moving away from alphabetical order to a custom sequence (Nederlands, Deutsch, English, French).
Initial Solutions Proposed:
Manual editing of the language-localization.liquid file in theme code
Note that language selectors typically sort alphabetically, with popular countries sometimes prioritized
Working Solution:
A custom liquid script was provided to be added via Customizer > Custom liquid section in Footer. This JavaScript code sorts both Country and Language selectors by reordering DOM elements.
Issue & Fix:
The initial code broke language switching functionality because it recreated HTML elements, removing event handlers. The solution was updated to use appendChild() instead of innerHTML, which moves elements while preserving their attached event handlers.
Status: Resolved. The corrected code successfully reorders languages while maintaining switching functionality.
Summarized with AI on October 30.
AI used: claude-sonnet-4-5-20250929.
Usually, country list is sorted alphabetically, but, say Dawn (and your theme too) can sort countries which are popular in your store to the beginning of the list.
However, they are still should be sorted alphabetically by name, so I do not quite understand how you’re getting the initial list.
But you can still sort them the way you like. While this can be done in liquid, this will require editing your theme code which will make further updates difficult.
So instead go to Customizer, add a “Custom liquid” section to your “Footer” section group and paste this code:
This code should work for Dawn and Craft and will sort both Country and Language selectors.
If not – let me know the store URL and I will have a further look.
@tim_1 . Sorry, I was to fast. With the liquid script the order can be rearranged. That works perfect, only problem is that after adding the code the language doesn’t switch anymore to a selected language. Any idea how to solve that?