language_selector.html 921 B

1234567891011121314151617181920212223
  1. {% load i18n %}
  2. {% get_language_info_list for LANGUAGES as languages %}
  3. {% if settings.USE_MODELTRANSLATION and languages|length > 1 %}
  4. {# hide submit button if browser has javascript support and can react to onchange event #}
  5. <script>$(document).ready(function(){$('#language_selector_form').change(function(){this.submit();});$('#language_selector_form input').hide();});</script>
  6. <div>
  7. <form action="{% url "set_language" %}" method="post" id="language_selector_form">
  8. {% csrf_token %}
  9. <div class="form-group">
  10. <select name="language" class="form-control">
  11. {% for language in languages %}
  12. <option value="{{ language.code }}"
  13. {% if language.code == LANGUAGE_CODE %}selected="selected"{% endif %}>
  14. {{ language.name_local }}
  15. </option>
  16. {% endfor %}
  17. </select>
  18. </div>
  19. <input type="submit" class="btn btn-default" value="{% trans "Change" %}" />
  20. </form>
  21. </div>
  22. {% endif %}