Improved language handling

This commit is contained in:
Oleg Lavrovsky 2018-06-22 15:06:59 +02:00
parent c7f0fea8ae
commit 1d8d8d019d
5 changed files with 14 additions and 9 deletions

View File

@ -1 +1 @@
{{ contact.trans_title_styled|safe }}
{% if html %}{{ contact.trans_title_styled|safe }}{% else %}{{ contact.trans_title }}{% endif %}

View File

@ -44,5 +44,6 @@ def contact_links(site_root):
# Styled contact name (header)
@register.inclusion_tag('tags/contact_name.html')
def contact_name(site_root):
return { 'contact': get_contacts(site_root)['contact'] }
def contact_name(site_root, html=True):
contactname = get_contacts(site_root)['contact']
return { 'contact': contactname, 'html': html }

View File

@ -8,8 +8,11 @@ class TranslatedField(object):
def __get__(self, instance, owner):
if translation.get_language() == 'fr':
return getattr(instance, self.fr_field)
val = getattr(instance, self.fr_field)
elif translation.get_language() == 'en':
return getattr(instance, self.en_field)
val = getattr(instance, self.en_field)
else:
return getattr(instance, self.de_field)
if not val:
return getattr(instance, self.de_field)
return val

View File

@ -1,10 +1,11 @@
{% load compress static wagtailuserbar %}
{% load compress static wagtailuserbar navigation information %}
{% get_site_root as site_root %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}{% endblock %}{% block title_suffix %}{% endblock %}</title>
<title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{% if page.trans_title %}{{ page.trans_title }} - {% endif %}{% contact_name site_root=site_root html=False %}{% endif %}{% endblock %}{% block title_suffix %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{% block description %}{% endblock %}">

View File

@ -30,8 +30,8 @@
</footer>
<div class="copyright">
&copy; 2018 Public Health Schweiz
&bull; <a href="/privacy/">Privacy Terms</a>
&copy; 2018 {% contact_name site_root=site_root %}
&bull; <a href="/privacy/">Privacy</a>
&bull; <a href="/impressum/">Impressum</a>
</div>