RM en from available_languages close #330 / hide lang menu if only one language installed close #350 / The menu lang is generated from the config

This commit is contained in:
Marc Ducobu 2014-11-21 15:03:09 +01:00
parent 47bbd6eca4
commit 9e05755f28
3 changed files with 19 additions and 13 deletions

View File

@ -52,9 +52,9 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface
$twigConfig = array(
'globals' => array(
'installation' => array(
'name' => $config['installation_name']
),
'date_format' => 'd-M-Y'
'name' => $config['installation_name']),
'date_format' => 'd-M-Y',
'available_languages' => $config['available_languages']
),
'form' => array(
'resources' => array('ChillMainBundle:Form:fields.html.twig'))

View File

@ -27,6 +27,7 @@ class Configuration implements ConfigurationInterface
->defaultValue('Chill')
->end()
->arrayNode('available_languages')
->defaultValue(array('fr'))
->prototype('scalar')->end()
->end()
->end();

View File

@ -50,16 +50,21 @@
'layout': 'ChillMainBundle::Menu/user.html.twig',
}) }}
<li class="nav-link more"><a href="">{{ app.request.locale | upper }}</a>
<ul class="submenu">
{% for locale in ['fr', 'nl', 'en'] %}
<li {% if locale == app.request.locale %}class="active"{% endif %}>
<a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale' : locale})) }}">{{ locale | upper }}</a>
</li>
{% endfor %}
</ul>
</li>
{% if available_languages|length == 1 %}
<li class="nav-link">
<a href="">{{ available_languages[0] | upper }}</a>
</li>
{% else %}
<li class="nav-link more"><a href="">{{ app.request.locale | upper }}</a>
<ul class="submenu">
{% for lang in available_languages %}
<li {% if lang == app.request.locale %}class="active"{% endif %}>
<a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale' : lang})) }}">{{ lang | upper }}</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
</ul>
</div>
</header>