Reputation:
I would like to disable translations or force using english ones for paths which starts with /admin
.
Is there a way to approach it in config?
If not what would be the best practice? EventListener
checking routes and forcing english translation no matter the locale set in request?
Upvotes: 1
Views: 395
Reputation: 4880
taken from the docs:
app.admin:
resource: '@AppBundle/Controller/Admin/'
type: annotation
prefix: /{_locale}/admin
requirements:
_locale: nl
put the locale in the url, this is much more search engine friendly. As the docs say:
A better policy is to include the locale in the URL. This is fully-supported by the routing system using the special _locale parameter:
Upvotes: 0
Reputation: 883
Depending on how you import your routes you can also set the default locale on it and no other options to set it (example routing.yml):
app:
resource: '@AppBundle/Controller/'
type: annotation
app.admin:
resource: '@AppBundle/Controller/Admin/'
type: annotation
prefix: /admin
defaults:
_locale: nl
Upvotes: 1
Reputation: 1507
I think the EventListener
approach is the most comfortable: http://symfony.com/doc/current/translation/locale.html
Set the locale within Request
object. Hint: you can check a route name using _route
attribute instead of checking an absolute URL.
Upvotes: 0