PHPackages                             dartmoon/laravel-localized-routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. dartmoon/laravel-localized-routes

ActiveLibrary[Localization &amp; i18n](/categories/localization)

dartmoon/laravel-localized-routes
=================================

Localize laravel routes and views

v1.3.4(3mo ago)12.1k↓27.8%[1 issues](https://github.com/dartmoon-io/laravel-localized-routes/issues)MITPHP

Since May 16Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/dartmoon-io/laravel-localized-routes)[ Packagist](https://packagist.org/packages/dartmoon/laravel-localized-routes)[ RSS](/packages/dartmoon-laravel-localized-routes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (0)

Laravel Localized Routes
========================

[](#laravel-localized-routes)

A simple package to localize the routes of Laravel. This pakage adds some macros to the `Route` facade to allow the localization. There are also some helpers.

Installation
------------

[](#installation)

```
composer require dartmoon/laravel-localized-routes
```

Usage
-----

[](#usage)

1. Group all the routes you want to translate inside a `Route::localize(...)`. This must be put at the topmost group level of your routes.

```
Route::localize(function () {
    // Put here all the routes you want to localize
});
```

2. For each route that you want to localize change the method with the localized one. The localized version has a `Localized` suffix.

E.g. if this is your route file

```
Route::group(function () {
    Route::get('/home', ...);
    Route::post('/update-profile', ...);

    Route::get('/do/not/localize');
});

Route::get('/external');
```

Then it must become

```
Route::localize(function () {
    Route::getLocalized('/home', ...);
    Route::postLocalized('/update-profile', ...);

    Route::get('/do/not/translate/but/prefix');
});

Route::get('/external');

// If you are using livewire or you need some routes
// prefixed with the current locale
Route::localizeCurrentLocale(function () {
    Livewire::setUpdateRoute(function ($handle) {
        return Route::post('livewire/update', $handle);
    });
});
```

3. You can now translate all your routes using the Laravel translation service. Inside the your lang folder (eg. `/lang/it`) create a `routes.php` file.

```
