Mercurial > libervia-templates
diff sat_templates/templates/default/base/base.html @ 183:240bbac435f4
base: implemented language button:
- `component.menu` can now be used with a `{% call %}`, allowing extra HTML to be added after in the <nav> element
- a language dropdown is shown if more than one translation is available, allowing to change page locale
- if javascript is available, only the dropdown is visible, and changing it reload the page with new locale
- if javascript is not available, a submit button is display to change the locale
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 10 Apr 2019 21:05:58 +0200 |
parents | 178f55b825b7 |
children | cda2aad3eed0 |
line wrap: on
line diff
--- a/sat_templates/templates/default/base/base.html Wed Apr 10 21:05:56 2019 +0200 +++ b/sat_templates/templates/default/base/base.html Wed Apr 10 21:05:58 2019 +0200 @@ -67,7 +67,22 @@ <body> {% if main_menu %} {% block main_menu %} - {{ component.menu(main_menu, class="main_menu") }} + {% call component.menu(main_menu, class="main_menu") %} + <form action="" method="get" class="menu__language"> + <select name="{{C.KEY_LANG}}" id="{{C.KEY_LANG}}" onchange="this.form.submit()"> + {% if locales|length>1 %} + {% for l in locales %} + <option value="{{l}}" {{"selected" if l==locale}}> + {{l.language_name}} + </option> + {% endfor %} + {% endif %} + </select> + <button type="submit" class="menu__language-btn"> + {% trans %}change{% endtrans %} + </button> + </form> + {% endcall %} {% endblock main_menu %} {% endif %}