I have multiple routes for different locales:
Example:
Route for /de
$routes['industry'] = array(
'route' => 'branche/:type',
'defaults' => array(
'module' => 'default',
'controller' => 'index',
'action' => 'branche',
'type' => 'automobil'
),
'reqs' => array(
'type' => '(automobil|textil)'
)
);
Route for /en
$routes['industry'] = array(
'route' => 'industry/:type',
'defaults' => array(
'module' => 'default',
'controller' => 'index',
'action' => 'branche',
'type' => 'car'
),
'reqs' => array(
'type' => '(car|textile)'
)
);
Its possible somehow to have just one route instead of 2 on this case?
Note is not just the route which changes, also the type on the reqs and the default type.
I see two different routes there Usually the internationalisation is on the page but not on the url
Let me be clear, you keep your url and with a parameter in the url you know the language of the page so
$routes['industry'] = array(
'route' => 'industry/:lang/:type',
'defaults' => array(
'module' => 'default',
'controller' => 'index',
'action' => 'branche',
'type' => 'car',
'lang' => 'en'
),
'reqs' => array(
'lang' => '(en|de)',
'type' => '(car|textile)'
)
);
and depending of the parameter lang you display the correct message on your twig or phtml or html
Another way to do this changing the url is:
$routes['industry'] = array(
'route' => ':industry/:type',
'defaults' => array(
'module' => 'default',
'controller' => 'index',
'action' => 'branche',
'type' => 'car',
'industry' => 'industry'
),
'reqs' => array(
'industry' => '(industry|branche)',
'type' => '(car|textile)'
)
);
I found the solution for the translations here:
https://dasprids.de/blog/2009/04/01/translated-segments-for-standard-route/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With