Skip to content

Commit

Permalink
language selector is called by hyperscript
Browse files Browse the repository at this point in the history
  • Loading branch information
andywar65 committed Feb 10, 2024
1 parent f806999 commit e93447c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions project/templates/htmx/select_language.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

<a class="btn btn-outline-secondary me-2"
title="{% trans 'Set language' %}"
hx-get="{% url 'select_language' %}"
hx-target="#selectlanguage">
script="on click hide me then show #language-selector">
<i class="fa fa-language fa-lg"></i>
</a>
<form id="language-selector" class="row me-1" action="{% url 'set_language' %}" method="POST" style="display: none">
{% csrf_token %}
<div class="col-auto">
<input name="next" type="hidden" value="{% url 'home' %}">
<select class="form-control" name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }}
</option>
{% endfor %}
</select>
</div>
<div class="col-auto">
<button class="btn btn-primary" type="submit">{% translate 'Set language' %}</button>
</div>
</form>

0 comments on commit e93447c

Please sign in to comment.