Switching language through url locale not working
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Switching language through url locale not working
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.
Re: Switching language through url locale not working
First of all, you need to update to 2021.10.x LTS because 2021.07 isn't supported any more.
Do you use the Aimeos distribution as base or a custom Laravel setup with Aimeos package added?
Do you use the Aimeos distribution as base or a custom Laravel setup with Aimeos package added?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Switching language through url locale not working
Okay I will update shortly. I doubt it causes the issue tho. I am using a custom larvel setup with Aimeos package added.
Re: Switching language through url locale not working
If you use a custom Laravel setup, you have to add a few things yourself:
- https://github.com/aimeos/aimeos/blob/m ... Locale.php
- https://github.com/aimeos/aimeos/blob/m ... er.php#L46
- https://github.com/aimeos/aimeos/blob/m ... hp#L16-L23
- https://github.com/aimeos/aimeos/blob/m ... el.php#L24
- https://github.com/aimeos/aimeos/blob/m ... el.php#L67
- https://github.com/aimeos/aimeos/blob/m ... Locale.php
- https://github.com/aimeos/aimeos/blob/m ... er.php#L46
- https://github.com/aimeos/aimeos/blob/m ... hp#L16-L23
- https://github.com/aimeos/aimeos/blob/m ... el.php#L24
- https://github.com/aimeos/aimeos/blob/m ... el.php#L67
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Switching language through url locale not working
By reading the provided documentations and fixing the corresopnding parts of my project, I managed to resolve the issue. Thanks!