Created
September 1, 2015 02:23
-
-
Save migmolrod/63be83ccbaf2a0db3fa4 to your computer and use it in GitHub Desktop.
Adding a translatable language switcher to JMSI18nRoutingBundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
locale: 'es_ES' | |
locales: [ 'de', 'en_GB', 'es_ES', 'fr' ] | |
jms_i18n_routing: | |
default_locale: %locale% | |
locales: %locales% | |
twig: | |
globals: | |
lang: | |
locale: %locale% | |
locales: %locales% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{% for locale in lang.locales %} | |
{% set current = (app.request.locale == locale) %} | |
<li> | |
<a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': locale})) }}"> | |
{{ locale|trans({}, 'lang', locale) }} | |
{{ current ? '✓' : '' }} | |
</a> | |
</li> | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment