footer links localized (#6707)
This commit is contained in:
parent
5785e1fd1a
commit
c1b3c04446
|
@ -1,9 +1,37 @@
|
|||
import json
|
||||
import os
|
||||
import requests
|
||||
import xml.etree.ElementTree as ET
|
||||
from slugify import slugify
|
||||
|
||||
from pylons import config as pconfig
|
||||
|
||||
import ckan.plugins as plugins
|
||||
import ckan.plugins.toolkit as toolkit
|
||||
from ckan.lib.app_globals import set_global
|
||||
|
||||
def footer_links():
|
||||
url = 'https://www.ozwillo.com/footer.xml'
|
||||
langs = {}
|
||||
|
||||
response = requests.get(url)
|
||||
menuset = ET.fromstring(response.text.encode('utf-8'))
|
||||
|
||||
items = ('News', 'Discovering', 'Co-construct', 'Let\'s go', 'Contact',
|
||||
'Projects', 'Project team', 'Ozwillo', 'User guide', 'Developers',
|
||||
'Legal Notices', 'General terms of use')
|
||||
|
||||
|
||||
for menu in menuset.findall('menu'):
|
||||
locale = menu.find('locale').text
|
||||
c = 0
|
||||
langs[locale] = {}
|
||||
for item in menu.findall('item'):
|
||||
if 'href' in item.attrib:
|
||||
langs[locale][slugify(items[c])] = item.get('href')
|
||||
c += 1
|
||||
return langs
|
||||
|
||||
|
||||
class OzwilloThemePlugin(plugins.SingletonPlugin):
|
||||
plugins.implements(plugins.IConfigurer)
|
||||
|
@ -14,6 +42,8 @@ class OzwilloThemePlugin(plugins.SingletonPlugin):
|
|||
set_global('ckan.ozwillo_portal_url',
|
||||
pconfig.get('%s.ozwillo_portal_url' % __name__))
|
||||
|
||||
set_global('ckan.footer_links', footer_links())
|
||||
|
||||
toolkit.add_template_directory(config_, 'templates')
|
||||
toolkit.add_public_directory(config_, 'public')
|
||||
toolkit.add_resource('fanstatic', 'theme')
|
||||
|
|
|
@ -17,25 +17,25 @@
|
|||
</div>
|
||||
<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
|
||||
<ul class="nav navbar-nav navbar-footer">
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/news">{% trans %}News{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/discover">{% trans %}Discovering{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/co-construct">{% trans %}Co-construct{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/let-s-go">{% trans %}Let's go{% endtrans %}</a></li></ul>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['news'] }}">{% trans %}News{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['discovering'] }}">{% trans %}Discovering{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['co-construct'] }}">{% trans %}Co-construct{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['lets-go'] }}">{% trans %}Let's go{% endtrans %}</a></li></ul>
|
||||
</div>
|
||||
<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
|
||||
<ul class="nav navbar-nav navbar-footer">
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/contact">{% trans %}Contact{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/l-equipe-projet-oasis">{% trans %}Project team{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/projects">{% trans %}Projects{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['contact'] }}">{% trans %}Contact{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['project-team'] }}">{% trans %}Project team{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['projects'] }}">{% trans %}Projects{% endtrans %}</a></li>
|
||||
<li><a class="ext-twitter" href="https://twitter.com/ozwillo">@Ozwillo</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
|
||||
<ul class="nav navbar-nav navbar-footer">
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/guide-utilisateur">{% trans %}User guide{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['user-guide'] }}">{% trans %}User guide{% endtrans %}</a></li>
|
||||
<li><a href="http://doc.ozwillo.com/">{% trans %}Developers{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/legal-notices">{% trans %}Legal Notices{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/terms">{% trans %}General terms of use{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['legal-notices'] }}">{% trans %}Legal Notices{% endtrans %}</a></li>
|
||||
<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['general-terms-of-use'] }}">{% trans %}General terms of use{% endtrans %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in New Issue