I'm trying to implement the locale in the routes.
I can get it to work like host/en/page
& host/fr/page
with this snippet:
#routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
prefix: /{_locale}
requirements:
_locale: nl|en
But my goal is to be able to use host/page
where the locale would not be in the url, but is set as a default locale.
How do I do this? I can't find it anywhere in the documentation.
Edit, trying out the JMSI18nRoutingBundle
additions:
# config.yml
jms_i18n_routing:
default_locale: nl
locales: [nl, en]
strategy: prefix_except_default
.
# security.yml > firewalls section
form_login:
login_path: _login
check_path: _login
csrf_token_generator: security.csrf.token_manager
logout:
path: _logout
target: /
.
# routing.yml
_logout:
path: /logout
options: { i18n: false }
_login:
path: /login
options: { i18n: false }
Routes are prefixed as they should, but I'm unable to use my login and logout routes.