I work with Symfony 2 on a site that has 2 languages, and I want to change the patterns of my routes depending on the user's language!
Example:
user_login_en: pattern: /en/user/login.html defaults: { _controller: SfErrorsAppBundle:User:login, _locale: en } user_login_fr: pattern: /fr/utilisateur/connexion.html defaults: { _controller: SfErrorsAppBundle:User:login, _locale: fr}
Inside the template, this is not complicated, I just need to pass $ this-> get ('session') → getLocale () from the controller to the template ...
To work, I have to call my routes:
$router->generate('user_login_'.$locale, array());
But inside my layouts, I have menus and sidebars that have links ... Therefore, I want the locale variable to use it! So my question is simple: how to get this variable inside the "layout" template? Otherwise, do you have an idea to change the template depending on the language?
The reasons are that I want beautiful routes for all users, whether English or French ... And also because of SEO!
layout templates symfony routing translation
Sybio Aug 02 2018-11-21T00: 00Z
source share