Language switcher tag
This commit is contained in:
parent
793a052b4f
commit
3a8ddd7afd
4 changed files with 27 additions and 5 deletions
3
publichealth/home/templates/tags/language.html
Normal file
3
publichealth/home/templates/tags/language.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
{% for lang in languages %}
|
||||
<a{% if lang.code == currentlangcode %} class="active"{% endif %} href="/{{ lang.code }}/home">{{ lang.title }}</a>
|
||||
{% endfor %}
|
14
publichealth/home/templatetags/navigation.py
Normal file
14
publichealth/home/templatetags/navigation.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django import template
|
||||
from django.utils import translation
|
||||
|
||||
register = template.Library()
|
||||
|
||||
# Language switcher
|
||||
@register.inclusion_tag('home/templates/tags/language.html', takes_context=True)
|
||||
def language_switcher(context):
|
||||
return {
|
||||
'languages': [ { 'code': 'de', 'title': 'De' }, { 'code': 'fr', 'title': 'Fr' } ],
|
||||
'currentlangcode': translation.get_language(),
|
||||
'request': context['request'],
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
{% load wagtailcore_tags navigation %}
|
||||
|
||||
<nav class="navbar-pre navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="nav">
|
||||
<span class="contact-nav">
|
||||
<a class="link" href="#contact">Kontakt</a>
|
||||
<a href="tel:+41313899286">
|
||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||
<span class="hidden-xs">+41 31 389 92 86</span></a>
|
||||
<a href="mailto:info@public-health.ch">
|
||||
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
|
||||
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
|
||||
<span class="hidden-xs">info@public-health.ch</span></a>
|
||||
</span>
|
||||
<span class="language-nav">
|
||||
<a class="active" href="/de/home">De</a>
|
||||
<a href="/fr/home">Fr</a>
|
||||
{% language_switcher %}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -27,7 +28,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/de/home"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
||||
<a class="navbar-brand" href="/de/home"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
||||
<span class="hidden-xs"><strong>Public Health</strong> Schweiz</span></a>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -53,3 +53,7 @@ grunt browser-sync
|
|||
A default browser should open pointing to the default home page.
|
||||
|
||||
Now access the admin panel with the user account you created earlier: http://localhost:3000/admin/
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- Issues with migrating database tables in SQLite during development? Try `./manage.py migrate --fake`
|
||||
|
|
Loading…
Reference in a new issue