Skip to content

Instantly share code, notes, and snippets.

@tomblanchard
Created April 27, 2020 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomblanchard/e96535fc8390012a01995d494d8e73c3 to your computer and use it in GitHub Desktop.
Save tomblanchard/e96535fc8390012a01995d494d8e73c3 to your computer and use it in GitHub Desktop.
var element = document.querySelector('[data-module-language-selector]');
if (element) {
element.addEventListener('change', (event) => {
window.location = event.target.value;
});
}
<select data-module-language-selector>
{% for locale in shop.published_locales %}
{% assign locale_active = false %}
{% if locale.iso_code == request.locale.iso_code %}
{% assign locale_active = true %}
{% endif %}
<option value="{{ locale.root_url }}" {% if locale_active %}selected{% endif %}>
{{ locale.name }}
</option>
{% endfor %}
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment