Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

khanareeb's avatar

Laravel Localisation mcamara/laravel-localization Locale changed to 'en' when navigate to catagories OR products

Hi,

So I am using the laravel package mcamara/laravel-localization for the localisation.. Everything is set and package is working in most of the scenarios except 1. So i have the ecommerce website on which i have installed this package.. When i chane the local to another language. it gives the url like this http://127.0.0.1:8000/ar which is perfect. But when i navigate to any of the category it removes the selected local http://127.0.0.1:8000/

It is working fine when i navigate to another pages (user account, registed etc) BUT not working for the categories & products details (In short any of the route which has the {{id}}/{{slug}})

I have set the route inside the route group for the localisation but still it is not working as expected on this scenario. Does anyone gone through with this problem?

I am sharing my code snippet for routes please can any body help me out on this? frustrated

Working fine on this scenario

Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{

 // customer account dashboard
Route::controller(UserController::class)->group(function(){
Route::get('/user/order/page' , 'UserOrderPage')->name('user.order.page');
 Route::post('/return/order/{order_id}' , 'ReturnOrder')->name('return.order');

 Route::get('/return/order/page' , 'ReturnOrderPage')->name('return.order.page');

}); 

});

Not working for the categories routes OR the product details routes

Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{
Route::get('/product/details/{id}/{slug}', [IndexController::class, 'ProductDetails']);

Route::get('/catalog/product/category/{id}/{slug}', [IndexController::class, 'CatWiseProduct'])->name('categories.route');

Route::get('/catalog/product/subcategory/{id}/{slug}', [IndexController::class, 'SubCatWiseProduct'])->name('subcategory.route');
});;

````
0 likes
0 replies

Please or to participate in this conversation.