Update Routes Configuration:
Add the following code to yourapp/config/routes.php
before the $builder->fallbacks();
line:
$langs = getRouterLangs();
$builder->connect('/{lang}/{plugin}/{controller}/{action}/*', [], ['lang' => $langs, 'persist' => ['lang', 'plugin']]);
$builder->connect('/{lang}/{plugin}/{controller}', [], ['lang' => $langs, 'persist' => ['lang', 'plugin']]);
$builder->connect('/{lang}/{controller}/{action}/*', [], ['lang' => $langs, 'persist' => ['lang']]);
$builder->connect('/{lang}/{controller}', [], ['lang' => $langs, 'persist' => ['lang']]);
$builder->connect('/{plugin}/{controller}/{action}/*', [], ['persist' => ['plugin']]);
$builder->connect('/{plugin}/{controller}', [], ['persist' => ['plugin']]);
Modify Existing Routes:
If you have existing routes in routes.php
or plugin routes.php
, update them as shown below:
$langs = getRouterLangs();
$builder->connect('/{lang}/dashboard', ['controller' => 'Users', 'action' => 'dashboard'], ['lang' => $langs, 'persist' => ['lang']]);
$builder->connect('/dashboard', ['controller' => 'Users', 'action' => 'dashboard']);
$builder->connect('/{lang}/stats/*', ['controller' => 'Visits', 'action' => 'index'], ['lang' => $langs, 'persist' => ['lang']]);
$builder->connect('/stats/*', ['controller' => 'Visits', 'action' => 'index']);