Step by step solution :
Step1 : Add Laravel Localization to your composer.json file
“mcamara/laravel-localization”: “1.1.*”
Step2 : Run composer install to get the latest version of the package.
Step3 : Open config/app.php and find the providers key. Add LaravelLocalizationServiceProvider to the array.
Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class
Step4 : You can also add an alias to the list of class aliases in the same file.
‘LaravelLocalization’ => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class
Step5 : you have to register the middleware in the app/Http/Kernel.php file like this
protected $routeMiddleware = [
‘localize’ => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
];
Step6: Run following
php artisan vendor:publish –provider=”Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider”
Step7 : Open this file : config/laravellocalization.php
Step8 : enable your language by default en and es ebale
Step9 : Configure your route like
Route::group(
[
‘prefix’ => LaravelLocalization::setLocale(), // this wll return language
‘middleware’ => [ ‘localize’] // Route translate middleware
], function() {
Route::get(‘/’,function(){
return view(‘welcome’);
});
});
Your URL will looks like
example localhost/laravel/en , localhost/laravel/es , localhost/laravel/fr
Thanks
Step by step solution :
Step1 : Add Laravel Localization to your composer.json file
“mcamara/laravel-localization”: “1.1.*”
Step2 : Run composer install to get the latest version of the package.
Step3 : Open config/app.php and find the providers key. Add LaravelLocalizationServiceProvider to the array.
Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class
Step4 : You can also add an alias to the list of class aliases in the same file.
‘LaravelLocalization’ => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class
Step5 : you have to register the middleware in the app/Http/Kernel.php file like this
protected $routeMiddleware = [
‘localize’ => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
];
Step6: Run following
php artisan vendor:publish –provider=”Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider”
Step7 : Open this file : config/laravellocalization.php
Step8 : enable your language, by default en and es enable
Step9 : Configure your route like
Route::group(
[
‘prefix’ => LaravelLocalization::setLocale(), // this wll return language
‘middleware’ => [ ‘localize’] // Route translate middleware
], function() {
Route::get(‘/’,function(){
return view(‘welcome’);
});
});
Your URL will looks like
example localhost/laravel/en , localhost/laravel/es , localhost/laravel/fr
Thanks