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( $twigConfig = array(
'globals' => array( 'globals' => array(
'installation' => array( 'installation' => array(
'name' => $config['installation_name'] 'name' => $config['installation_name']),
), 'date_format' => 'd-M-Y',
'date_format' => 'd-M-Y' 'available_languages' => $config['available_languages']
), ),
'form' => array( 'form' => array(
'resources' => array('ChillMainBundle:Form:fields.html.twig')) 'resources' => array('ChillMainBundle:Form:fields.html.twig'))

View File

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

View File

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