Skip to main content
Fix bad copy/paste from OP
Source Link

To those like @liquidcms wondering how to do a multilingual path : you can make as many routes as languages, to the same controller.

custom.route.lang_one:
  path: '/path/in/this/language'
  defaults:
    _content_controller: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

custom.route.lang_two:
  path: '/path/in/that/other/language'
  defaults:
    _content_controller: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

And then you check the language in the controller as already mentioned by @4k4.

To those like @liquidcms wondering how to do a multilingual path : you can make as many routes as languages, to the same controller.

custom.route.lang_one:
  path: '/path/in/this/language'
  defaults:
    _content: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

custom.route.lang_two:
  path: '/path/in/that/other/language'
  defaults:
    _content: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

And then you check the language in the controller as already mentioned by @4k4.

To those like @liquidcms wondering how to do a multilingual path : you can make as many routes as languages, to the same controller.

custom.route.lang_one:
  path: '/path/in/this/language'
  defaults:
    _controller: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

custom.route.lang_two:
  path: '/path/in/that/other/language'
  defaults:
    _controller: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

And then you check the language in the controller as already mentioned by @4k4.

Source Link

To those like @liquidcms wondering how to do a multilingual path : you can make as many routes as languages, to the same controller.

custom.route.lang_one:
  path: '/path/in/this/language'
  defaults:
    _content: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

custom.route.lang_two:
  path: '/path/in/that/other/language'
  defaults:
    _content: '\Drupal\my_module\Controller\MyController::method'
  requirements:
    _permission: 'access content'

And then you check the language in the controller as already mentioned by @4k4.