From 38d0e6da9a38e5caa014ceeb673984fabf7e7b3a Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Thu, 28 Jun 2018 15:58:20 +0200 Subject: [PATCH] Add page language --- publichealth/home/templatetags/navigation.py | 5 +++++ publichealth/templates/base.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/publichealth/home/templatetags/navigation.py b/publichealth/home/templatetags/navigation.py index c390457..2201486 100644 --- a/publichealth/home/templatetags/navigation.py +++ b/publichealth/home/templatetags/navigation.py @@ -4,6 +4,10 @@ from django.utils import translation register = template.Library() +@register.simple_tag() +def language_cur(): + return translation.get_language() + # Language switcher @register.inclusion_tag('tags/language.html', takes_context=True) def language_switcher(context): @@ -22,6 +26,7 @@ def language_switcher(context): { 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') }, { 'code': 'fr', 'title': 'Fr', 'url': url.replace('$lang$','fr') } ] + # TODO: make language list configurable if context['page'].get_site().root_page.slug == "sphc": language_array.append({ 'code': 'en', 'title': 'En', 'url': url.replace('$lang$','en') }) return { diff --git a/publichealth/templates/base.html b/publichealth/templates/base.html index e776d33..349d8e2 100644 --- a/publichealth/templates/base.html +++ b/publichealth/templates/base.html @@ -1,7 +1,7 @@ {% load compress static wagtailuserbar navigation information %} {% get_site_root as site_root %} - +