Simple locale prefixed routes for Laravel
coopbelvedere/laravel-localized-url is a Laravel package for simple locale prefixed routes for laravel.
It currently has 0 GitHub stars and 25 downloads on Packagist (latest version v1.0.1).
Install it with composer require coopbelvedere/laravel-localized-url.
Discover more Laravel packages by coopbelvedere
or browse all Laravel packages to compare alternatives.
Last updated
This is a laravel package to create simple locale prefixed routes and setting that locale in your laravel app. Be careful if you choose to use this package, as no more features will be added. For a more complete solution, please use Laravel Localization Package.
php artisan vendor:publish --provider="Belvedere\LocalizedUrl\LocalizedUrlServiceProvider"
In the app/config/localized-url.php file:
Set default_locale_redirect to true if you want the default language to
be removed from the url when accessed directly.
The locales key are the locales allowed in your url. If it's an array, it
will use those locales, but you can also pass a key from another config file,
like app.locales if you already have this set in your application.
You can add the locale prefix to your app/Providers/RouteServiceProvider.php:
use Belvedere\LocalizedUrl\LocalizedUrlFacade as LocalizedUrl;
class RouteServiceProvider extends ServiceProvider
{
...
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->prefix(LocalizedUrl::urlPrefix())
->group(base_path('routes/web.php'));
}
Also add \Belvedere\LocalizedUrl\Middleware\RedirectLocale::class, to your
web stack in app/Http/Middleware/Kernel.php for the redirections to work.
You're all set!
If you feel that's more what you need, you can consider using the Laravel Localization Package instead.
Copyright (c) 2017-present, Coopérative Belvédère Communication