Laravel Multilingual Routes is an extension package of Chin Leung to register multilingual routes for your application. Instead of the following routing settings:
Route::get('/', 'ShowHomeController')->name('en.home'); Route::get('/fr', 'ShowHomeController')->name('fr.home');
You can accomplish the same thing with this extension package:
Route::multilingual('/', 'ShowHomeController')->name('home');
This package also comes with a middleware that automatically detects and changes the application's based on the request. regional settings.
protected $middlewareGroups = [ 'web' => [ \ChinLeung\LaravelMultilingualRoutes\DetectRequestLocale::class, // ... ] ];
You can configure the required language through the chinleung/laravel-locales package:
// config/locales.php 'supported' => [ 'en', 'es', 'fr', ],
Please be sure to check the README of the package, It contains examples of everything a multilingual package can do. You can learn more about this package at chinleung/laravel-multilingual-routes, get complete installation instructions, and view the source code on GitHub.
For more Laravel related technical articles, please visit the Laravel Framework Getting Started Tutorial column to learn!
The above is the detailed content of Laravel registers multi-language routing. For more information, please follow other related articles on the PHP Chinese website!