New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

richarddobron/laravel-localized-routes

Laravel Package for managing localized routes in Laravel applications.
16,179 1
Install
composer require richarddobron/laravel-localized-routes
Latest Version:2.0.5
PHP:^8.0
Laravel:9 – 13
Older releases:7 · 8
License:MIT
Last Updated:Jun 6, 2026
Links: GitHub  ·  Packagist
Maintainer: dobron
Laravel Localized Routes

Laravel Package for managing localized routes in Laravel applications.

📖 Requirements

  • Laravel 7.0 or higher
  • Composer is required for installation

📦 Installing

Install the library using Composer:

$ composer require richarddobron/laravel-localized-routes

⚡️ Quick Start

1. Publish the configuration

$ php artisan vendor:publish --provider="richarddobron\LocalizedRoutes\LocalizedRouteServiceProvider" --tag="config"

This will create config/localized-routes.php.

2. Configure supported locales

<?php

return [
    'prefix' => true,
    'locales' => [
        'de',
        'it',
        // ...
    ],
    'route_key' => 'locale',
    'route_locale' => 'en',
    'redirect_code' => 302,
];

3. Add routes. Example below shows how translations work.

Routes that get translated

Create a translation file like routes/lang/de/routes.php:

<?php

return [
    'example' => 'beispiel',
];

Then in routes/web.php:

Route::localeGroup([], function () {
    Route::get('/example', function () {
        return 'Hello, World!';
    });
});

This makes these URLs:

  • /example (default)
  • /de/beispiel
  • /it/example

Routes with parameters

You can give different paths per language:

Route::get('/book/{sku}', function (string $sku) {
    return 'Book details ' . $sku;
})->name('book')->locale([
    'de' => 'buch/{sku}',
    'it',
]);

This makes these URLs:

  • /book/{sku} (default)
  • /de/buch/{sku}
  • /it/book/{sku}

⚙️ Configuration Options

You can customize the library with the following configuration options.

Option Description Default
prefix Automatically prepends locale codes (/de, /it, etc.) to routes. true
locales List of supported locales. []
route_key The route parameter key used for locale identification. locale
route_locale Locale used for default routes. en
redirect_code HTTP status code used for redirecting to the correct localized route. 302

🧪 Testing

$ composer tests

🤝 Contributing

Please see CONTRIBUTING for details.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

Related Packages

laravel-lang/routes

Easy and fast way to localize routes

4,030,879 8
laravelista/loki

Laravel localization done right.

16,727 78
netstudio/loki

Laravel localization done right.

5,723 0
avnir/easyrouting

Make route handling in Laravel easier

280 0
leon-b/sextant

Get a list of laravel routes in your browser

20 0

Version History

Version Released PHP Laravel License
2.0.5 ^8.0 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
2.0.4 ^8.0 ^9.0|^10.0|^11.0 MIT
2.0.3 ^8.0 ^9.0|^10.0|^11.0 MIT
2.0.2 ^8.0 ^9.0|^10.0|^11.0 MIT
2.0.1 ^8.0 ^9.0|^10.0|^11.0 MIT