Switching language through url locale not working
Posted: 17 May 2022, 09:52
I am using Laravel Framework Version 7.30.4 with php 7.4 and Aimeos 2021.07 on an Windows Environment.
We already had an existing laravel project with locale functionality. There the locale always comes right after the domain, so a URL could look like this: example.com/en/some-page. To configure aimeos the same way, I edited the routes inside /config/shop.php to look like this:
'routes' => [
'admin' => ['prefix' => '{locale}/admin', 'middleware' => ['web']],
'jqadm' => ['prefix' => '{locale}/admin/{site}/jqadm', 'middleware' => ['web', 'auth']],
'jsonadm' => ['prefix' => '{locale}/admin/{site}/jsonadm', 'middleware' => ['web', 'auth']],
'jsonapi' => ['prefix' => 'jsonapi', 'middleware' => ['web', 'api']],
'account' => ['prefix' => '{locale}/profile', 'middleware' => ['web', 'auth']],
'default' => ['prefix' => '{locale}/shop', 'middleware' => ['web']],
'supplier' => ['prefix' => '{locale}/s', 'middleware' => ['web']],
'update' => [],
],
This does seem to work at first, because I can now call all the aimeos URLs the same way, e.g. example.com/en/store. But if I change the locale, nothing gets translated. So as an example I can open example.com/de/store, which works, but everything is still completely in english. Any information on where the mistake lies is appreciated.
We already had an existing laravel project with locale functionality. There the locale always comes right after the domain, so a URL could look like this: example.com/en/some-page. To configure aimeos the same way, I edited the routes inside /config/shop.php to look like this:
'routes' => [
'admin' => ['prefix' => '{locale}/admin', 'middleware' => ['web']],
'jqadm' => ['prefix' => '{locale}/admin/{site}/jqadm', 'middleware' => ['web', 'auth']],
'jsonadm' => ['prefix' => '{locale}/admin/{site}/jsonadm', 'middleware' => ['web', 'auth']],
'jsonapi' => ['prefix' => 'jsonapi', 'middleware' => ['web', 'api']],
'account' => ['prefix' => '{locale}/profile', 'middleware' => ['web', 'auth']],
'default' => ['prefix' => '{locale}/shop', 'middleware' => ['web']],
'supplier' => ['prefix' => '{locale}/s', 'middleware' => ['web']],
'update' => [],
],
This does seem to work at first, because I can now call all the aimeos URLs the same way, e.g. example.com/en/store. But if I change the locale, nothing gets translated. So as an example I can open example.com/de/store, which works, but everything is still completely in english. Any information on where the mistake lies is appreciated.