Skip to content

Commit

Permalink
Update README.md for Laravel 11 (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr-Moik authored Jul 24, 2024
1 parent 9b47bb7 commit 0164afa
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ class Kernel extends HttpKernel {
}
```

If you are using Laravel 11, you may register in `bootstrap/app.php` file in closure `withMiddleware`:

```php
return Application::configure(basePath: dirname(__DIR__))
// Other application configurations
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
/**** OTHER MIDDLEWARE ALIASES ****/
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class,
]);
})
```

## Usage

Add the following to your routes file:
Expand Down Expand Up @@ -386,6 +403,9 @@ It is necessary that at least the `localize` middleware in loaded in your `Route
For each language, add a `routes.php` into `resources/lang/**/routes.php` folder.
The file contains an array with all translatable routes. For example, like this:

> Keep in mind: starting from [Laravel 9](https://laravel.com/docs/9.x/upgrade#the-lang-directory), the `resources/lang` folder is now located in the root project folder (`lang`).
> If your project has `lang` folder in the root, you must add a `routes.php` into `lang/**/routes.php` folder.
```php
<?php
// resources/lang/en/routes.php
Expand Down

0 comments on commit 0164afa

Please sign in to comment.